Container Queries
ELI5 — The Vibe Check
Container Queries are the CSS feature we begged for years. Instead of 'how wide is the screen?' they ask 'how wide is my parent container?' Finally, a card component can adapt to its container whether it's in a sidebar or full-width. Components that truly own their responsiveness.
Real Talk
Container Queries are a CSS feature that allows elements to be styled based on the size of their containing element rather than the viewport. Using @container rules and container-type declarations, components can adapt their layout independently of the overall page dimensions.
Show Me The Code
.card-container { container-type: inline-size; }
@container (min-width: 400px) {
.card { display: grid; grid-template-columns: 1fr 1fr; }
}
When You'll Hear This
"Container queries make truly reusable components possible" / "No more media query breakpoints that only make sense in one layout"
Related Terms
CSS Nesting
CSS Nesting finally brings the one feature everyone used Sass for directly into plain CSS.
Progressive Enhancement
Progressive Enhancement is the philosophy of building the basics first (HTML that works), then layering on CSS and JavaScript like frosting on a cake.
Resize Observer
Resize Observer tells you when an element changes size. Not the window, the actual element.