Responsive design
Modern responsiveness is mostly not media queries: it is fluid values and intrinsically flexible layouts, with queries reserved for genuine rearrangement.
Method
- Start mobile, one column, content in priority order. The narrow
view forces the hierarchy conversation; widening is additive.
Desktop-first CSS accumulates unsetting rules (
float: none,width: auto) that exist only to undo itself. - Make size fluid before making it conditional.
font-size: clamp(1rem, 0.9rem + 0.5vw, 1.25rem)and spacing built from the same pattern remove entire classes of breakpoints. Gridauto-fit/minmaxhandles card layouts with zero queries (see css-layout). - Break where the content breaks, not at device names. Widen the window until the design looks wrong; that width is the breakpoint. Device-name breakpoints (768px "tablet") encode 2015's hardware into your stylesheet.
- Query the container for components. A card in a sidebar and the
same card full-width need different layouts at the same viewport size.
container-type: inline-sizeon the wrapper, then@container (min-width: 24rem)in the component. Media queries remain for page-level rearrangement and user preferences. - Handle the non-width axes.
@media (prefers-reduced-motion),(prefers-color-scheme),(hover: none)for touch, and dynamic viewport units (dvh) so mobile browser chrome does not eat your full-height layouts. Test landscape phones; 400px tall is real. - Let images do their part.
srcset/sizesfor resolution,aspect-ratioto reserve space against layout shift,object-fit: coverfor art-directed crops.
Boundaries
- Hiding content at small sizes is a product decision, not a CSS convenience; if it is not worth showing on mobile, question whether it is worth showing at all.
- Fluid type needs floor and ceiling; unclamped viewport math fails accessibility zoom and ultrawide monitors.
- JS-measured breakpoints drift from CSS ones; if scripts must know the layout, read a custom property set by the same query.