Skip to main content
UI/UX

Fluid Grids vs Container Queries: Which Wins for Responsive UI?

Responsive design isn't dead, but the tools have changed. I compare old-school fluid grids with modern container queries and argue that container queries win for component-driven UIs—with one big caveat.

The biggest myth in responsive web design is that media queries based on viewport width are still the best way to build adaptive interfaces. That's wrong. For most modern sites—especially ones built with components—container queries are the sharper tool. But that doesn't mean you should throw out fluid grids. Let's compare the two approaches on the criteria that actually matter: flexibility, granularity, performance, and accessibility.

Flexibility: Container Queries Adapt to the Component, Not the Screen

Fluid grids have served us well. They use relative units like percentages, fr units, and vw to make elements scale with the viewport (MDN Web Docs). That's a solid foundation. But a grid is only as flexible as its context. A sidebar widget on a desktop might be 300px wide; on a mobile phone, it's full-width. A media query can only respond to the viewport, not to the actual space the component lives in. That's a problem when the same component appears in different containers—say, a card that's placed in a narrow sidebar on one page and a wide content column on another.

Container queries solve this by letting a component respond to the size of its container, not the viewport (MDN Web Docs). The syntax is clean: you define a container with container-type: inline-size, then use @container (min-width: 400px) to adjust the layout. Container query units like cqw (1% of container width) and cqi (1% of container inline size) let you size elements relative to that container. This is a genuine leap in flexibility. A card can be compact in a sidebar and expansive in a main column, without needing a media query that affects the entire page.

Granularity: Media Queries Are a Coarse Brush; Container Queries Are a Fine Pen

Fluid grids rely on breakpoints. The standard advice is to add breakpoints when content demands them, not at fixed device sizes (MDN Web Docs). But even with that discipline, a viewport-based breakpoint is a blunt instrument. It applies to the whole page, so a single component might need to be overridden multiple times to behave well in different parts of the layout. Container queries give you component-level control. You can design a button, a form field, or a navigation menu to adapt to its own space. That's the kind of granularity that UI/UX designers crave.

But granularity comes at a cost: browser support. Container queries are Baseline Widely available, meaning they're supported in all major browsers since February 2023 (MDN Web Docs). That's good news. But if you need to support older browsers, you'll need a fallback. Fluid grids are universally supported, no fallback needed. So the choice isn't purely technical; it's also about your target audience.

Performance: Both Can Be Fast, but One Is More Predictable

Performance is often cited as a reason to stick with media queries, but that's a misconception. The real performance bottleneck isn't the CSS querying method; it's the content. Images, fonts, and JavaScript are the heavyweights. That said, container queries can be slightly more efficient because they allow you to write less CSS. Fewer rules mean less to parse and apply. But there's a subtle risk: container queries can cause layout recalculations if you're not careful. For example, if you have nested containers, a change in one can trigger style recalculation in the other. In practice, the impact is negligible for most pages.

What matters more for user experience is how fast the page loads and responds. Core Web Vitals are the standard: LCP should be 2.5 seconds or less, INP 200 milliseconds or less, and CLS 0.1 or less (web.dev). None of these are directly tied to whether you use media queries or container queries. Instead, focus on image dimensions, lazy loading, and avoiding layout shifts. Set both width and height on images so space is reserved before load (MDN Web Docs). That's a tip that works regardless of your layout approach.

Accessibility: The Overlooked Differentiator

Here's where I take a hard stance: accessibility is the most important criterion, and it often tips the scale toward fluid grids. Why? Because container queries can inadvertently break reflow. WCAG 2.1 Level AA requires that content be presented without loss of information or two-dimensional scrolling at a width equivalent to 320 CSS pixels (W3C WCAG 2.1 Understanding Reflow). That's a strict test. If you're using container queries to create a multi-column layout within a small container, you might end up with horizontal scrolling inside that container. You must ensure that content can reflow vertically when space is tight.

Fluid grids, using percentages and flexible units, naturally reflow because they're based on the viewport. Container queries require you to explicitly handle the small-container case with a @container (min-width: 0) query that switches to a single column. That's an extra step, and it's easy to forget. The same goes for text resizing. WCAG 2.1 requires text to be resizable up to 200% without loss of content (W3C WCAG 2.1 Understanding Resize Text). If your container query sets a fixed width for a text block, zooming could clip content. Use relative units like em or rem for font sizes, and avoid viewport units alone because they prevent zooming (MDN Web Docs).

In my opinion, the accessibility edge goes to fluid grids, because they're simpler and less likely to cause reflow issues. But that doesn't mean container queries are inherently inaccessible—you just need to be vigilant.

Which One Should You Use?

Let's cut to the chase. If you're building a marketing site with a mostly linear layout—a header, a hero, some sections, a footer—fluid grids with media queries are perfectly fine. They're simple, robust, and universally supported. Breakpoints at roughly 375px, 768px, 1024px, and 1440px cover most devices (MDN Web Docs).

But if you're building a component library, a dashboard, or a site with complex, nested layouts—where the same component appears in wildly different container sizes—container queries are the winner. They give you the granularity and flexibility that media queries can't match. The browser support is there, and the performance is fine if you're careful.

My recommendation: use container queries for the components that need them, and use fluid grids for the overall page structure. That's the best of both worlds. But don't ignore accessibility. Test your container query breakpoints with 320px width and 200% zoom. If you can't guarantee reflow, stick with media queries.

Criterion Fluid Grids + Media Queries Container Queries
Flexibility Adapt to viewport only Adapt to container size
Granularity Coarse, page-level Fine, component-level
Browser Support Universal Baseline Widely available since Feb 2023
Accessibility Risk Lower Higher if not tested

Who is each for? Fluid grids are for anyone who wants a safe, predictable layout that works everywhere. Container queries are for teams building design systems or component-driven sites that need precise control over how components behave in different contexts. If you're a solo designer-developer working on a brochure site, container queries are overkill. If you're on a product team, they're a game-changer.

Quick tip: In your container query, always include a @container (max-width: 400px) query to switch to single-column layout, and test it with a 320px viewport.

The single most important thing to remember is this: your layout should serve your content and your users, not the other way around. If you're using a technique that makes it harder to deliver accessible, high-performing content, you're using the wrong tool.

Sources

  • MDN Web Docs - https://developer.mozilla.org/en-US/docs/Web/CSS/@container
  • W3C WCAG 2.1 Understanding Reflow - https://www.w3.org/WAI/WCAG21/Understanding/reflow.html
  • W3C WCAG 2.1 Understanding Resize Text - https://www.w3.org/WAI/WCAG21/Understanding/resize-text.html
  • web.dev (Web Vitals) - https://web.dev/articles/vitals
  • StatCounter Global Stats - https://gs.statcounter.com/platform-market-share/desktop-mobile-tablet

Share this article:

Comments (0)

No comments yet. Be the first to comment!