Testing

CSS Container Query Units: Support, Units, Examples

CSS container query units (cqw, cqh, cqi, cqb, cqmin, cqmax) work in Chrome 105+, Edge 105+, Firefox 110+, Safari 16+, Opera 91+, Samsung Internet 20+.

Author

Prince Dewani

May 5, 2026

CSS container query units are W3C CSS length units (cqw, cqh, cqi, cqb, cqmin, cqmax) that size values relative to a 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 never added support.

This guide covers what they are, the browsers that support them, the six available units, how to use them, and the known issues.

What are CSS container query units?

CSS container query units are six relative length units defined in the W3C CSS Conditional Rules Module Level 5: cqw, cqh, cqi, cqb, cqmin, and cqmax. Each unit equals one percent of a parent query container's width, height, inline size, block size, smaller axis, or larger axis.

Which browsers support CSS container query units?

CSS container query units work in every browser that supports CSS container queries, with Chrome and Edge first in version 105, Safari in version 16, and Firefox in version 110.

Loading browser compatibility data...

CSS container query units compatibility in Chrome

Chrome supports CSS container query units from Chrome 105 on Windows, macOS, Linux, ChromeOS, and Android. Chrome 93 to 100 had cqw, cqh, cqi, and cqb behind the chrome://flags/#enable-container-queries flag, and Chrome 4 to 92 did not parse any cq length unit. All six units (cqw, cqh, cqi, cqb, cqmin, cqmax) ship in the same Chrome 105 release.

CSS container query units compatibility in Edge

Microsoft Edge supports CSS container query units from Edge 105 on Windows, macOS, Linux, and Android. The feature is on by default with no flag, since Edge tracks the Chromium 105 base. Edge 12 to 104 did not parse cqw, cqh, cqi, cqb, cqmin, or cqmax.

CSS container query units compatibility in Firefox

Firefox supports CSS container query units from Firefox 110 on Windows, macOS, Linux, and Android. No flag is required. Firefox 2 to 109 did not parse cqw, cqh, cqi, cqb, cqmin, or cqmax, so any rule that used them was discarded by the parser.

CSS container query units compatibility in Safari

Safari supports CSS container query units from Safari 16 on macOS Ventura and from Safari 16 on iOS and iPadOS. The desktop and mobile builds ship the same six units together (cqw, cqh, cqi, cqb, cqmin, cqmax). Safari 3.1 to 15.6 on macOS and Safari on iOS before version 16 did not support any cq length unit.

CSS container query units compatibility in Opera

Opera supports CSS container query units from Opera 91 on Windows, macOS, Linux, and Android, mirroring the Chromium 105 base. Opera 79 to 90 had the units behind the same enable-container-queries flag as Chrome, and earlier Opera versions did not parse them. Opera Mobile 80 and later support cqw, cqh, cqi, cqb, cqmin, and cqmax on Android.

CSS container query units compatibility in Samsung Internet

Samsung Internet supports CSS container query units from Samsung Internet 20 on Galaxy phones and tablets. Samsung Internet 4 to 19 did not parse cqw, cqh, cqi, cqb, cqmin, or cqmax. The browser tracks the Chromium 105 base for parity with desktop Chrome.

CSS container query units compatibility in Android Browser

The Chromium-based Android Browser supports CSS container query units from version 105, matching desktop Chrome. The legacy stock Android Browser, frozen at Android 4.4, does not parse any cq length unit. Use Chrome for Android, Firefox for Android, or Samsung Internet on modern Android phones for full cqw, cqh, cqi, cqb, cqmin, and cqmax support.

CSS container query units compatibility in Internet Explorer

Internet Explorer never added support for CSS container query units. IE 5.5 through IE 11 do not recognize cqw, cqh, cqi, cqb, cqmin, or cqmax, and any rule that uses them is discarded by the parser. Microsoft has retired Internet Explorer 11 and recommends Edge for any site that needs container query units.

Note

Note: CSS container query units fall back to the small viewport unit when the parent container is missing container-type, and the trap fires differently in Safari, Firefox, and Chrome. Test cqw, cqh, cqi, and cqb on real browsers and OS with TestMu AI. Try TestMu AI free!

What are the available CSS container query units?

The CSS Conditional Rules Module Level 5 defines six container query length units. Each unit measures one percent of a parent container's width, height, inline size, block size, smaller axis, or larger axis, and falls back to the small viewport unit on its axis when no eligible container is found.

  • cqw: One percent of the query container's width. If the container is 800px wide, 50cqw equals 400px. cqw always tracks the physical horizontal axis, regardless of writing-mode.
  • cqh: One percent of the query container's height. If the container is 300px tall, 10cqh equals 30px. cqh always tracks the physical vertical axis, regardless of writing-mode.
  • cqi: One percent of the query container's inline size. cqi equals cqw in horizontal writing modes and cqh in vertical writing modes, so a component sized in cqi flips axes when the page switches to a vertical script like Japanese tate-chu-yoko.
  • cqb: One percent of the query container's block size. cqb equals cqh in horizontal writing modes and cqw in vertical writing modes. Pair cqb with cqi for layouts that adapt to writing-mode.
  • cqmin: The smaller of cqi or cqb. If the container is 800px wide and 300px tall in horizontal writing-mode, 50cqmin equals 150px. cqmin keeps a square or aspect-ratio-locked element from stretching beyond the shorter axis.
  • cqmax: The larger of cqi or cqb. With the same 800 by 300 container, 50cqmax equals 400px. cqmax sizes hero badges and full-bleed media against the longer axis of the container.

How do you use CSS container query units?

Container query units only resolve inside a query container, so the parent must declare container-type before any cq value works. Once the container is declared, any descendant can use cqw, cqh, cqi, cqb, cqmin, or cqmax in place of vw or vh.

  • Declare a container on the parent: Set container-type: inline-size for width-based sizing, or container-type: size for both axes. inline-size is the safer default since size also containment forces the block axis and can collapse children with no fixed height.
  • Pick the right unit for the axis: Use cqi for inline sizing that adapts to writing-mode, cqw for fixed horizontal sizing, cqb for block-axis sizing, and cqmin or cqmax for symmetric scaling on both axes.
  • Wrap cq values in clamp() or calc() for safe ranges: font-size: clamp(1rem, 4cqi, 1.5rem) keeps the font readable when the container is very small or very large, instead of letting cq scale linearly past usable sizes.
  • Combine cq units with @container size queries: Use cq units for fluid sizing inside the container, and @container (min-width: 480px) blocks for layout shifts that flip from a single column to a grid.
  • Verify the rule fires in DevTools: Open the Elements panel in Chrome 105+ or Safari 16+, click the container badge next to the parent, and resize the container to confirm cqw, cqh, cqi, and cqb update at the right breakpoint.
/* Step 1: Declare a container on the parent */
.product-card {
  container-type: inline-size;
  container-name: card;
}

/* Step 2: Use cq units so children scale with the card, not the viewport */
.product-card h2 {
  font-size: clamp(1rem, 4cqi, 1.5rem);
  padding-inline: 2cqi;
}

.product-card .thumbnail {
  width: 100cqw;
  aspect-ratio: 16 / 9;
}

/* Step 3: Combine cq units with @container size queries for layout shifts */
@container card (min-width: 480px) {
  .product-card {
    display: grid;
    grid-template-columns: 40cqi 1fr;
    gap: 2cqi;
  }
}

If a cq value resolves to the viewport instead of the container, container-type is missing on the closest ancestor; the closest container with container-type wins, so check the cascade in DevTools.

...

What are the known issues with CSS container query units?

CSS container query units are stable across modern browsers, but the spec has a few traps that catch teams the first time they ship cq values in production.

  • cq units fall back to the small viewport unit: If no ancestor declares container-type, every cq value resolves against the small viewport (sv*) on its axis, so 100cqw renders as 100svw. The fallback is silent and produces a layout that looks correct on desktop but breaks inside narrow containers.
  • inline-size containers expose only the inline axis: A container with container-type: inline-size resolves cqi, cqw, cqmin, and cqmax against the container, but cqh and cqb fall back to the viewport. Use container-type: size when a child needs both axes, and accept the block-axis containment that comes with it.
  • cq units cannot be used in @container conditions: The condition list inside @container (min-width: 30cqi) is invalid. cq units only resolve inside descendant rules, so the breakpoint values must be px, rem, em, or another absolute or font-relative unit.
  • Containers cannot size themselves with their own cq units: A container's own width or height cannot reference its own cqw or cqh, since container-type triggers layout containment and would create a circular dependency. Apply cq sizing to descendants only.
  • Logical-property bugs in early Safari 16 builds: Safari 16.0 and 16.1 had cases where cqi and cqb resolved against the viewport when the container used display: contents. The fix shipped in Safari 16.4, so set the testing baseline at Safari 16.4 if cqi sizing is critical.
  • No fallback inside @container: Browsers older than Chrome 105, Edge 105, Firefox 110, or Safari 16 skip the entire @container block, so any layout the block sets is lost. Provide a baseline outside the @container with px, rem, or vw values for older browsers.

In my experience, the small-viewport fallback bites teams the most. A card that renders correctly on a desktop preview suddenly looks giant inside a 320px sidebar, because the inline-size container higher up the tree got removed during a refactor and every cqi value silently switched to svi. The fix is to add a regression test that asserts a known cqw value matches the parent width, not the viewport.

...

Citations

All CSS container query unit 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