Grid gaps and the flexbox caveat
Spacing elements with margins in CSS is a recurring problem. The gap property handles it cleanly in grid contexts, but it cannot yet be relied on everywhere: in flexbox layouts, gap support currently exists only in Firefox, so a flexbox layout built around it will break elsewhere.
.grid {
display: flex;
gap: 10px;
}
Responsiveness without media queries
A technique popularized by Andy Bell builds a fully responsive layout with no media queries at all:
.grid {
display: grid;
grid-gap: 10px;
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
The declaration repeat(auto-fill, minmax(150px, 1fr)) sets up the following behavior:
- A 10px gap separates every column and row.
- Each column has a 150px minimum width.
- Each column is equal width (
1fr). - The grid auto-fills as many columns as fit.
Because of minmax, the grid is effectively responsive: resize the browser and it snaps down into fewer columns, with no breakpoints involved.
Designing around behavior
The interesting part isn't that media queries are avoided — it's the shift in mental model that the technique forces. As Chase McCoy puts it, instead of using breakpoints to specify the screen size at which items should stack, you specify the minimum size an element must reach before it stacks. That framing encourages developers to describe responsive design in terms of behaviors rather than screen sizes.
"Behaviors instead of screen sizes" is a more durable way to approach component design. Fixing components to the usual mobile, tablet and desktop buckets tends to produce problems, because many factors beyond viewport width affect what a component needs to do.

A component may need to sit inside another component, for example, or to have helper text aligned alongside it for comparison. Sizing it by behavior covers those cases; sizing it by screen does not.
The container query prerequisite
Behavior-driven sizing can't be done fully today. Container queries are consistently among the most requested CSS improvements, and the general argument is that if they existed, developers would write far fewer global, page-size media queries. What is actually being controlled is a scoped container, and media queries are used for that job only because CSS offers no better tool. Until that changes, media-query-free techniques like the minmax grid remain the closest available approximation.



