<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>CSS Media Queries</title> <style> /* Smartphones (portrait and landscape) ---------- */ @media screen and (min-width: 320px) and (max-width: 480px){ body{ background: purple; } } /* Smartphones (portrait) ---------- */ @media screen and (max-width: 320px){ body{ background: yellow; } } /* Smartphones (landscape) ---------- */ @media screen and (min-width: 321px){ body{ background: skyblue; } } /* tablets, iPads (portrait and landscape) ---------- */ @media screen and (min-width: 768px) and (max-width: 1024px){ body{ background: purple; } } /* tablets, iPads (portrait) ---------- */ @media screen and (min-width: 768px){ body{ background: yellow; } } /* tablets, iPads (landscape) ---------- */ @media screen and (min-width: 1024px){ body{ background: orange; } } /* Desktops and laptops ---------- */ @media screen and (min-width: 1224px){ body{ background: red; } } /* Large screens ---------- */ @media screen and (min-width: 1824px){ body{ background:green; } } </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>Note:</strong> Media queries allow you to adjust the display of your web pages for a certain range of devices like as mobile phones, tablets, desktops, and so on, without changing the markup.</p> </body> </html>