Testing

CSS Container Queries: Browser Support, Features, Limits

CSS container queries work in Chrome 105+, Edge 105+, Firefox 110+, Safari 16+, Opera 91+, and Samsung Internet 20+. Learn CSS container queries support.

Author

Prince Dewani

May 5, 2026

CSS container queries are a W3C CSS Containment feature that styles a child element based on the size or style of its parent container, not the viewport. They work in Chrome 105+, Edge 105+, Firefox 110+, Safari 16+ on macOS and iOS, Opera 91+, and Samsung Internet 20+, while Internet Explorer has no support.

This guide covers what CSS container queries are, the browsers that support them, their features, how they differ from media queries, the syntax, and known issues.

What is CSS container queries?

CSS container queries are a CSS Containment Module Level 3 feature from the W3C CSS Working Group. They use the @container at-rule and the container-type and container-name properties to style child elements based on the size or computed style of a parent container, so one component can adapt to many layout slots without checking the viewport.

Which browsers does CSS container queries support?

CSS container queries work in every modern desktop and mobile browser, with Chrome and Edge first in version 105, Safari in version 16, and Firefox in version 110.

Loading browser compatibility data...

CSS container queries compatibility in Chrome

Chrome supports CSS container queries from Chrome 105 on Windows, macOS, Linux, ChromeOS, and Android. Chrome 92 to 104 had the feature behind the chrome://flags/#enable-container-queries flag, and Chrome versions before 92 did not support @container at all. Chrome 111 added style queries on CSS custom properties, and Chrome 133 added scroll-state container queries.

CSS container queries compatibility in Edge

Microsoft Edge supports CSS container queries from Edge 105 on Windows, macOS, Linux, and Android. The feature is on by default, with no flag required. Edge 12 to 104 did not support @container or container query units. Edge 111 added style queries on CSS custom properties to match the Chromium upstream.

CSS container queries compatibility in Firefox

Firefox supports CSS container queries from Firefox 110 on Windows, macOS, Linux, and Android. No flag is needed. Firefox 2 to 109 did not support @container or any container query units. Firefox does not yet support style queries or scroll-state queries; teams targeting Firefox can rely on size queries only.

CSS container queries compatibility in Safari

Safari supports CSS container queries from Safari 16 on macOS Ventura and from Safari 16 on iOS and iPadOS. Both platforms ship size queries and the cqw, cqh, cqi, cqb, cqmin, and cqmax units. Safari 18 added style queries on CSS custom properties on macOS Sequoia and iOS 18. Safari 3.1 to 15.6 on macOS and Safari on iOS before version 16 did not support @container.

CSS container queries compatibility in Opera

Opera supports CSS container queries from Opera 91 on Windows, macOS, Linux, and Android, tracking the Chromium 105 base. Opera 79 to 90 had the feature behind the same enable-container-queries flag as Chrome, and earlier Opera versions did not support it. Opera Mobile 80 and later support container queries on Android.

CSS container queries compatibility in Samsung Internet

Samsung Internet supports CSS container queries from Samsung Internet 20 on Galaxy phones and tablets. Samsung Internet 4 to 19 did not support @container. Samsung Internet 22 added style queries on CSS custom properties for parity with the Chromium 111 base.

CSS container queries compatibility in Android Browser

The Chromium-based Android Browser supports CSS container queries from version 105, matching desktop Chrome. The legacy stock Android Browser, frozen at Android 4.4, does not support @container or container query units. Use Chrome for Android, Firefox for Android, or Samsung Internet on modern Android phones for full container query support.

CSS container queries compatibility in Internet Explorer

Internet Explorer never added support for CSS container queries. IE 5.5 through IE 11 do not recognize the @container at-rule, container-type, container-name, or any cq length unit. Microsoft has retired Internet Explorer 11 and recommends Edge for any site that needs container queries.

Note

Note: CSS container queries behave differently in Safari, Firefox, and Chrome around style queries and unsized containers. Test them on real browsers and OS with TestMu AI. Try TestMu AI free!

What are the key features of CSS container queries?

CSS container queries cover three query types and six length units, all driven by the @container at-rule and the container-type property.

  • Size queries: Match a parent container's width or height with rules like @container (width > 480px) or @container card (max-width: 320px). Size queries are the most widely supported variant and ship in every browser that supports @container.
  • Style queries: Match a parent container's computed style, currently limited to CSS custom properties in Chrome 111+, Edge 111+, Opera 97+, and Safari 18+. Firefox does not yet support style queries.
  • Scroll-state queries: Match scroll position and stuck states, available in Chrome 133+ and Edge 133+. Safari, Firefox, and Samsung Internet have not shipped scroll-state queries.
  • Container query length units: Six relative units, cqw, cqh, cqi, cqb, cqmin, and cqmax, each measuring 1 percent of the query container's width, height, inline size, block size, smaller axis, or larger axis.
  • container-type property: Declares an element a query container with the values inline-size (recommended default), size (both axes), or normal (style queries only).
  • container-name property: Names a container so a child can target a specific ancestor with @container sidebar (width > 700px), instead of always falling back to the closest container.
  • container shorthand: Sets container-name and container-type in one declaration, written as container: card / inline-size on the parent element.
...

How do CSS container queries differ from media queries?

CSS container queries and media queries both gate styles behind a condition, but they query different scopes, target different elements, and reach different browsers. The table below maps the trade-offs that drive the choice between @container and @media for a layout.

DimensionCSS Container QueriesCSS Media Queries
Query scopeParent element with container-type set on itWhole viewport, browser window, or device
At-rule@container@media
Opt-in stepSet container-type on the parent before any query firesNone, every viewport always matches
Reusable componentsSame component restyles in any container widthComponent restyles only when the viewport changes
Length unitscqw, cqh, cqi, cqb, cqmin, cqmaxvw, vh, vmin, vmax, dvw, dvh
Browser reachChrome 105+, Edge 105+, Firefox 110+, Safari 16+, Opera 91+, Samsung Internet 20+Every modern browser plus Internet Explorer 9 and later
Performance costLayout containment runs on every container elementNone beyond the query check itself

How do you use CSS container queries?

Container queries take three steps: declare a container on the parent, name it if a child needs a specific target, and write @container rules that change child styles when the container matches a condition.

  • Declare a container: Set container-type: inline-size on the parent element. inline-size is the safer default; size also adds block-axis containment but can collapse children that have no fixed height.
  • Name the container (optional): Set container-name: card on the parent so a child can target this specific ancestor with @container card (...), instead of always querying the closest container.
  • Write the @container rule: Open @container card (width > 480px) and put any child selector and properties inside the block. The rule fires only when the named container matches.
  • Use container query units when sizing children: Replace vw or vh with cqw, cqh, cqi, or cqb so font-size, padding, and gaps scale with the container, not the viewport.
  • Test with DevTools: Open the Elements panel in Chrome 105+ or Safari 16+, click the container badge next to the parent, and resize to confirm the @container rule fires at the right breakpoint.
/* Step 1: Declare a containment context on the parent */
.card-grid {
  container-type: inline-size;
  container-name: card;
}

/* Step 2: Query the named container by width */
@container card (width > 480px) {
  .card {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 1rem;
  }
}

/* Step 3: Use container query units for fluid sizing */
@container card (width > 320px) {
  .card h2 {
    font-size: clamp(1.25rem, 4cqi, 2rem);
  }
}

If the rule never fires, container-type is most likely missing on the parent or set on the wrong ancestor; the closest ancestor with container-type wins, so check the cascade in DevTools.

What are the known issues with CSS container queries?

CSS container queries work cleanly across modern browsers, but the spec design has a few sharp edges that catch teams the first time they ship them.

  • A container cannot style itself: @container rules apply only to descendants. The container's own size and style cannot depend on its own queried conditions, since container-type triggers layout containment and would create a circular dependency.
  • Containers lose intrinsic sizing: container-type: size or inline-size forces explicit sizing on the container. An unsized container inside a flex or grid layout can collapse to zero width, especially when the parent uses align-items: stretch or grid-auto-rows: min-content.
  • Style queries are still narrow: Chrome 111+, Edge 111+, and Safari 18+ accept style queries on CSS custom properties only, and Firefox has not shipped any style query support. Style queries on standard properties like color or display remain experimental.
  • Reserved container names: container-name cannot use the reserved keywords default, none, at, no, or, or any other CSS-wide identifier. Pick names like card, sidebar, or hero to avoid parser errors.
  • Specificity is unchanged inside @container: A rule inside @container has the same specificity as the same rule outside, so an outer .card { color: red } can still beat @container (width > 400px) { .card { color: blue } } if source order or specificity is wrong.
  • No fallback inside @container: Browsers without container query support skip the entire @container block, so any layout the block sets is lost. Provide a media-query baseline outside the @container so older browsers still get a usable layout.

In my experience, the container-type sizing trap catches teams the most. A card that was happy in a flex layout collapses to zero width the moment you add container-type: inline-size to a flex item, because the parent stops sizing it from content. The fix is usually flex-basis: auto plus min-width: 0 on the container, or moving container-type onto a wrapper that already has explicit width.

...

Citations

All CSS container queries version numbers and platform notes in this guide come from these primary sources:

Author

Prince Dewani is a Community Contributor at TestMu AI, where he manages content strategies around software testing, QA, and test automation. He is certified in Selenium, Cypress, Playwright, Appium, Automation Testing, and KaneAI. Prince has also presented academic research at the international conference PBCON-01. He further specializes in on-page SEO, bridging marketing with core testing technologies. On LinkedIn, he is followed by 4,300+ QA engineers, developers, DevOps experts, tech leaders, and AI-focused practitioners in the global testing community.

Open in ChatGPT Icon

Open in ChatGPT

Open in Claude Icon

Open in Claude

Open in Perplexity Icon

Open in Perplexity

Open in Grok Icon

Open in Grok

Open in Gemini AI Icon

Open in Gemini AI

Copied to Clipboard!
...

3000+ Browsers. One Platform.

See exactly how your site performs everywhere.

Try it free
...

Write Tests in Plain English with KaneAI

Create, debug, and evolve tests using natural language.

Try for free

Frequently asked questions

Did you find this page helpful?

More Related Hubs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests