Name-only @container queries without size conditions

Container queries without size conditions

Until recently, @container always needed a size condition. To target a named context without caring about size, you wrote @container sidebar (width > 0). Browsers now accept the name on its own. Yes. aasdasdas

Old way Dummy size condition
.sidebar {  container-name: sidebar;}.card {  display: grid;}/* size condition required even when you only care about the name */@container sidebar (width > 0)   {  .card {    grid-auto-flow: column;  }}
Just the name
.sidebar {  container-name: sidebar;}.card {  display: grid;}@container sidebar   {  .card {    grid-auto-flow: column;  }}/* no dummy size condition */
Newly available Since 2026 Newly available global usage

Since 2026 this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Works in all modern browsers. May need a fallback for older browsers.

149+
148+
26.4+
149+

Name-only @container queries shipped across all three engines in April 2026 (Chrome 149, Safari 26.4, Firefox 148). The broader @container feature has been Baseline widely available since 2023, so older browsers will simply skip the rule.

same card, two contexts. Only the named sidebar container flips it to a row.
No name
Card title
Default stacking. The named rule does not apply here.
container-name: sidebar
Card title
Inside a named sidebar container. The rule fires and the card flips to a row.
@container sidebar { ... } only matches the right context

No more dummy condition

The pattern @container sidebar (width > 0) existed only to satisfy the parser. Drop the parentheses entirely now.

Context-only styling

Use it when a component should behave differently inside a named ancestor, regardless of size. Cards in a sidebar, items in a modal, anything with shared layout context.

Composes with size queries

You can still chain a size condition when you want one. @container sidebar (width > 400px) remains valid. Drop it when context is the only thing you care about.

Key Change
Optional size
Name alone is enough
Old Approach
@container name (width > 0)
Dummy condition required
Modern Approach
@container name
Name-only query

How it works

The @container rule originally required both a name and a condition. To target a named context without a real size threshold, the workaround was to write a condition that always passed, like (width > 0) or (min-width: 1px). The parens were ceremony, not logic.

The updated grammar makes the condition optional. @container sidebar { ... } now applies styles whenever the matched element is inside a container named sidebar, with no size check at all. It is the cleaner way to express "only when this component lives inside this context".

Pair it with size-based container queries when both matter. The name-only form is purely about scoping styles to a named ancestor.

ESC