In short
The same page has to look good on a ₹8,000 phone and a 27-inch monitor. Media queries let you change styles based on screen size and user preferences.
Media queries apply CSS only when a condition is true, such as a minimum screen width, so you can change layouts at chosen breakpoints.

Think of it like this
Dressing for the weather
You wear the same body every day but change clothes for Delhi winters and Chennai summers. Media queries are the 'if it's cold, wear a sweater' rules for your page: same HTML, different CSS depending on the screen.
Watch it happen
One card list, three screen widths
1/4On a phone, no query matches. The base styles give one column.
The big ideas
What you need to know
Mobile first
Write base styles for phones, then use min-width queries to add layout for bigger screens.
Breakpoints follow content
Add a breakpoint where your design starts to look bad, not at a list of specific phone models.
User preferences
prefers-color-scheme detects dark mode. prefers-reduced-motion tells you to calm down animations.
Container queries
@container lets a component react to its own box size instead of the whole screen. Supported in modern browsers.
See it in code
Walk through the code
1.cards { display: grid; gap: 1rem; } /* phone: one column */2 3@media (min-width: 640px) {4 .cards { grid-template-columns: 1fr 1fr; }5}6 7@media (min-width: 1024px) {8 .cards { grid-template-columns: repeat(3, 1fr); }9}10 11@media (prefers-color-scheme: dark) { body { background: #111; color: #eee; } }12 13@media (prefers-reduced-motion: reduce) {14 * { animation: none !important; transition: none !important; }15}1/4Base styles with no query are for phones: one column.
Mobile styles come first with no query. Each min-width block adds more columns as the screen grows.
Save yourself the pain
Common mistakes
Oops
Designing for desktop first and patching mobile with lots of max-width overrides.
Do this instead
Start with mobile. It's simpler to add layout than to undo it.
Oops
Forgetting the viewport meta tag and thinking media queries are broken.
Do this instead
Add <meta name="viewport" content="width=device-width, initial-scale=1"> first.
Your mission
One page, three looks
Quick check
With a mobile-first approach, what kind of media queries do you mostly write?
Go deeper
- 1Turn a one-column card list into two and then three columns with min-width queries.
- 2Choose breakpoints where your design breaks, not around specific phone models.
- 3Try prefers-color-scheme to match the user's dark mode setting.
Also part of these roadmaps
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.