Difference Between min-width and max-width in Media Queries
The min-width and max-width properties in CSS media queries define the range of viewport sizes where specific styles should apply. They are essential for creating responsive layouts that adapt to different devices.
min-width applies styles when the viewport is equal to or wider than the specified width — typically used in mobile-first design.
max-width applies styles when the viewport is equal to or narrower than the specified width — typically used in desktop-first design.
You can combine them to target specific ranges, such as tablets or mid-sized devices.
How would you write a media query that switches a two‑column layout on only when the viewport is at least 600 px wide?
If you have a container with max-width: 800px and a min-width: 500px media query, what layout will you see when the viewport is 750 px?
A component should collapse to a single column below 480 px, but on some phones it stays in two columns. Walk me through how you’d debug the media queries.
Why might adding a max‑width breakpoint after a mobile‑first min‑width rule cause unexpected styling on tablet screens?
We need a fluid grid that works from 320 px up to 1920 px while keeping CSS size low. How would you organize min‑width and max‑width queries to avoid overlap and reduce reflows?
A third‑party widget injects fixed‑width CSS that breaks our layout. How could you use min‑width / max‑width media queries to safely contain it without affecting the rest of the page?
Our legacy codebase uses many max‑width (desktop‑first) queries. How would you plan a migration to a mobile‑first, min‑width‑only approach across several teams while keeping the UI stable?
Discuss the long‑term maintenance trade‑offs of relying heavily on max‑width breakpoints versus a fluid, min‑width‑only system in a large design system.