Grandma Marni’s stall page on Mr. Karim’s sliding board: write @media, set the frame’s width or pick Dodi’s phone or Mr. Sugeng’s laptop, and the frame’s own…
Why it matters
Responsive design stands on @media. The wrong direction (desktop-first max-width) fills CSS with patches, the wrong order makes a breakpoint "not work", and forgetting prefers-reduced-motion gives animation that hurts motion-sensitive people.
The key idea
@media only switches rules on, it does not make them stronger
Common mistakes
Every new breakpoint adds another pile of overrides That is desktop-first max-width patching downward. Mobile-first (min-width) builds upward: base styles for phones, each breakpoint only adds.
Users report dizziness or nausea on an animation-heavy page They may have turned on "reduce motion" in their OS, but the CSS is not listening. Wrap non-essential animation in @media (prefers-reduced-motion: reduce) and switch it off.
The same component looks different in a narrow sidebar@media reads the viewport width, not the component’s. To make a component fit its parent’s room, use @container.
At exactly 640px, two rules apply at oncemax-width: 640px and min-width: 640px both match at 640px (both are inclusive). Use range syntax (width < 640px) and (width >= 640px), or just one direction (mobile-first).
Try it in this playground
Slide the board below 640px The 640px rule switches off and the grid falls back to the base: one column.
Write a three-column rule at 1024px and up yourself Add @media (min-width: 1024px) below the 640px rule, then slide right.
Open the "Reversed order" situation and look at 1100px Both rules match and the 640px one is written later, so it wins: still two columns.
Write a prefers-reduced-motion or prefers-color-scheme rule yourself Whether it matches depends on your device settings, not width. Compare with the Your device row.