Modern CSS gives you tools that make responsive, maintainable layouts simpler and more predictable. Instead of forcing components to adapt based only on viewport size, today’s features let styles respond to a component’s container, use flow-relative rules for different writing directions, and limit values with built-in math — all while keeping the cascade manageable.
Design components that respond to their container
Container queries let a component change its styles based on the space it’s actually placed in. Use @container with a named or implicit container and a condition on inline-size or aspect-ratio to swap layouts, font sizes, or gaps when a sidebar, card, or component column is narrow or wide. This reduces brittle media-query logic that assumes a global viewport.
Choose Grid and subgrid for two-dimensional layouts
CSS Grid is the right tool for many multi-row, multi-column designs. When you need nested alignment that shares the parent track sizes, subgrid lets a child adopt the parent’s grid tracks instead of redefining them. That keeps markup cleaner and makes alignment predictable across nested components.
Manage cascade and overrides with layers
The @layer at-rule adds named cascade layers so you can order large groups of styles (for example, resets, base, components, utilities) without relying on source order or overly specific selectors. Use layers to make third-party CSS less likely to accidentally override your design tokens or component rules.
Write international-friendly, future-proof rules
Logical properties (like margin-block, padding-inline, and inset-block-start) express layout relative to the writing mode rather than physical edges. They simplify styles for right-to-left locales and reduce the need for explicit directional overrides.
Use math functions for fluid sizing
Min/max/clamp functions let you express a preferred value while constraining it between a minimum and maximum. A common pattern for fluid typography is font-size: clamp(1rem, 2.5vw, 2rem); which grows with the viewport but never becomes unreadably small or excessively large. Combine these with min() and max() for robust layouts without many media queries.
Reduce layout shifts and reserve space
The aspect-ratio property is a simple way to reserve the right amount of space for images, video, and other replaced content at parse time. That reduces cumulative layout shift and avoids padding hacks.
Progressive enhancement and feature detection
Feature-detect new capabilities with @supports and ship graceful fallbacks for older engines. Polyfills or build-time CSS transforms can help with very old targets, but most modern browsers support these features. Where behavior differs, provide a simple fallback or use @supports blocks to isolate progressive enhancements.
Practical checklist
- Prefer Grid for 2D layouts; use
subgridwhen nested alignment must match parent tracks. - Scope component responsiveness with
@containerqueries rather than global media queries when possible. - Use
@layerto separate base, components, and utilities to avoid specificity wars. - Adopt logical properties to simplify RTL and international layouts.
- Use
clamp(),min(), andmax()for fluid sizes andaspect-ratioto reserve space. - Wrap new features in
@supportswhen targeting a broad audience and provide fallbacks.
These practices keep CSS maintainable, make components more portable, and reduce brittle viewport assumptions — all without sacrificing performance or accessibility when implemented with progressive enhancement.

