v142 · css
Range syntax for style container queries and if()
This feature enhances CSS style queries and the if() function by adding support for range syntax. This extends style queries beyond exact value matching (e.g., style(--theme: dark)). Developers can now use comparison operators (>, <, etc.) to compare custom properties, literal values (like 10px or 25%), and values from substitution functions like attr() a
concepts
-
Range Container Queries
Slide
--densityand--scalecustom properties — the card restyles whenever the value crosses a range threshold likestyle(--density >= 3). -
if() Thermostat
The other surface this work unlocks: the inline
if()function with style-range comparisons in a single property value. A thermostat reading drives background and text colour with three branches, all in pure CSS. -
Density Stepper
Two custom properties feeding eight overlapping range rules. Slide
--densityand--temp; data-tile padding, type size, and background restyle as each value crosses a band — pure CSS, no JS class toggling. -
CSS if() Playground
Write
if()expressions with range comparisons directly in a live CSS editor. Sliders drive the custom property values; the rendered card updates instantly. A syntax guide maps each comparison operator to its spec form, and a browser-support badge lights up when your engine parses the rule. -
Priority Card
A task card where
--priority(1–10) and--score(0–100) custom properties drive colour, border weight, padding, and visible sections via range style container queries.@container style(3 <= --priority <= 4)matches the "high" band; no JavaScript class toggling — CSS range arithmetic handles every state transition.
why it shipped
This feature enhances CSS style queries and the if() function by adding support for range syntax. This extends style queries beyond exact value matching (e.g., style(--theme: dark)). Developers can now use comparison operators (>, <, etc.) to compare custom properties, literal values (like 10px or 25%), and values from substitution functions like attr() a