@container style()
Newly availableSince 202688% of users
Lets you apply styles based on the value of a container's custom property, like @container style(--theme: dark), instead of only its size.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyModernIn every major browser since May 2026. Widely available around November 2028.
The old way and the modern waySee the snippet: Range style queries without multiple blocks →
Old way 19 lines
/* Multiple discrete checks */
@container style(--progress: 0%) {
.bar {
background: red;
}
}
@container style(--progress: 25%) {
.bar {
background: orange;
}
}
@container style(--progress: 50%) {
.bar {
background: yellow;
}
}
/* ... repeat for every threshold */
/* Or use JavaScript to set classes */
/* based on the numeric value */Modern 7 lines
@container style( /* [!code ++] */
--progress > 75% /* */
) {
.bar {
background: var(--green);
}
}See how modern your own CSS is.Check your CSS →
Quick example
@container style(--theme: dark) {
.card {
background: #1e1e2e;
color: #cdd6f4;
}
}Related snippet
Range style queries without multiple blocksWorkflow →@container style() browser support
BaselineNewly availableSince 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.
Usage88%of people can use this12% use a browser without it.
Browsers
111+
151+
18+
111+Mobile
111+Android
151+Android
18+iOS
Interop 2026 focus area. All major browsers are actively working to fix cross-browser inconsistencies for this feature in 2026. Learn more →