Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Example of CSS Media Queries</title> <style> /* Smartphones (portrait and landscape) ---------- */ @media screen and (min-width: 320px) and (max-width: 480px){ body{ background: #7ce7e1; } } /* Smartphones (portrait) ---------- */ @media screen and (max-width: 320px){ body{ background: #ffd280; } } /* Smartphones (landscape) ---------- */ @media screen and (min-width: 321px){ body{ background: #9ddfbb; } } /* tablets, iPads (portrait and landscape) ---------- */ @media screen and (min-width: 768px) and (max-width: 1024px){ body{ background: #ffb497; } } /* tablets, iPads (portrait) ---------- */ @media screen and (min-width: 768px){ body{ background: #f0e68c; } } /* tablets, iPads (landscape) ---------- */ @media screen and (min-width: 1024px){ body{ background: #d6b3f4; } } /* Desktops and laptops ---------- */ @media screen and (min-width: 1224px){ body{ background: #d8ff9d; } } /* Large screens ---------- */ @media screen and (min-width: 1824px){ body{ background: #ffc0cb; } } </style> </head> <body> <h1>CSS Media Queries</h1> <p>The background of the output area is different in different media or devices.</p> <p><strong>Alternative:</strong> You can also see the effect of this media query by opening the output in a new window and resize it to different sizes.</p> </body> </html>