Educational guide to @supports
Start with a working base and enhance it when supported
Choose the right query for each CSS capability and check what changes when its block enters the cascade.
Mental model
Write a base style outside the rule first. Inside @supports, add the declarations that enhance it when the browser supports the condition. When the condition is true, rules in the block enter the cascade with their usual order, layer, and specificity.
A declaration query tests a property and value pair. Write (display: grid) with parentheses. A made-up display value returns false and keeps block flow. A custom property accepts many values as text, so that query tests the custom property declaration itself.
Choose the rule for what you want to test. @supports queries a CSS capability, @media queries the environment, and @container queries a component’s context.
Block flow with a Grid enhancement
Made-up display value
Use the HTML from the Grid example to see block flow with this false condition.
Selector syntax
selector() tests the syntax of the entire selector. In the :has() recipe, the selector inside the block also needs a direct .item child to draw a solid outline. Remove the child in the playground and compare the match with the support query.
In a forgiving list such as :is(.item, :baseline-lab-unknown), the selector can match .item after dropping the unknown alternative. The selector() query also checks the arguments in the list and can return false.
Outline for a card with a direct child
At-rule names with at-rule()
at-rule() takes a single name such as @container. To check a more specific query type, try the declaration (container-type: scroll-state). Putting the prelude style(--test: 1) inside at-rule() returns false.
Use at-rule(@media) as a positive control for the function. @charset is an encoding declaration recognized by the stylesheet decoding algorithm, and at-rule(@charset) returns false. A made-up name also returns false.
The recipe registers --example-spacing with @property. The conditional block applies padding that depends on that registration. A valid initial value gives 24px. With a missing or invalid registration, var() uses 12px even when the @property query is true.
Spacing from a registered property
Controls for at-rule() and a more specific test
Behaviors with named-feature()
single-axis-scroll-container tests whether scroll and clip can be combined to scroll on one axis. anchor-position-follows-transforms tests whether positioning follows the anchor’s transforms. gamut-mapping tests mapping an out-of-gamut color into the destination space as defined by CSS Color.
In the tests on November 20, 2026, Chrome 158 returned true for single-axis scrolling and following transforms. Firefox 159 and WebKit 27.2 returned false for both names. All three returned false for gamut-mapping and the made-up name baseline-lab-unknown.
If every named query returns false, look for a positive control to confirm the function. You can also observe the behavior independently. In the anchor test, the positioned element followed the anchor in WebKit 27.2 and Chrome 158. In Firefox 159 it stayed in place.
Guarded scrolling and a direct declaration
Focus each area and use the arrow keys. The 30 px test requests scrolling on both axes and shows the computed values and the position reached.
Moving the anchor
Font technologies and formats
font-tech() queries a technology such as variations or COLRv1 color glyphs. font-format() queries a file format. Use the unquoted keyword woff2. The query with "woff2" returns false.
In the src descriptor of @font-face, format(woff2) and tech(variations) give the browser hints about the resource. format() also accepts legacy strings such as "woff2". Provide a fallback font-family or an alternative in src.
The card shows which CSS block applied. To check a specific font, inspect the resource response in Network and the face used for the glyphs in your browser’s font tools. A face in the loaded state helps verify loading. CSS.supports() checks the queried capability.
On November 20, 2026, variations and woff2 returned true in Chrome 158, Firefox 159, and WebKit 27.2. The result for color-COLRv1 was true in Chrome and Firefox and false in WebKit.
Font variations
WOFF2 format
Reuse the card HTML and query the format with the unquoted keyword.
Composition and nested rules
and requires every condition. or requires at least one. not inverts one complete condition. Use parentheses to combine and and or in the same prelude.
A rule with mixed operators and no grouping is invalid. An unknown function with balanced parentheses can fit the extensible grammar and evaluate to false. Negating it can activate the block. Use that last recipe as a diagnostic test.
When @container is nested inside @supports, the enhancement requires both rules to match. In the playground, changing the width from 10rem to 14rem crosses the 12rem threshold when enough space is available. Support for display: grid stays the same.
Grouped operators
The same operators without grouping
Use the same HTML. The invalid prelude leaves the base style in place.
Negating an unknown function
With the same HTML, not inverts the false result of the extensible condition.
Container size inside a support query
Conditional imports
Save the four files in the same directory and serve them over HTTP. In main.css, put @import before style rules and any other rules that cannot precede it. The first import provides the base and the second adds Grid when supported.
When the supports() condition is false, the browser skips fetching the stylesheet through that import. Another reference can still load the same file. Change grid to a made-up value and check Network and the computed display.
Import base and enhancement styles
The CSS.supports() API and if()
Call CSS.supports(property, value) to test a declaration. With CSS.supports(condition), pass a full query with parentheses, functions, or operators. The result is a boolean. Check the computed style or behavior to see what the cascade did.
if(supports(…): …) uses a support condition to choose the value of one declaration. Use @supports to condition a block of rules. The first declaration in the recipe provides the base value for engines that do not yet handle if().
The two CSS.supports() signatures
Choosing padding with if()
Syntax in development
The CSS Conditional Rules 5 draft proposes @supports env(<ident>) to query an environment variable by name. The (padding-top: env(safe-area-inset-top)) query checks the declaration. Inspect the used value to learn about the device geometry.
The same draft proposes @supports-condition to name a set of tests and reuse it with @supports (--name). The syntax and rule name are still under discussion. In the tests on November 20, 2026, both examples kept their base styles in Chrome, Firefox, and WebKit.
Draft environment query
Draft named condition
Common mistakes
Identify which part of the query, cascade, or scene produces the result.
The declaration query fails to apply the block
- Expected result
- The style improves when display accepts grid.
- Cause
- The prelude uses display: grid without the query parentheses.
- Solution
- Write @supports (display: grid) and keep the base style before the block.
Positive selector support with a dashed outline
- Expected result
- The card changes when the child is present.
- Cause
- selector(:has(> .item)) confirms the syntax. The selector in the block needs a direct .item child.
- Solution
- Check the HTML and whether the card matches. Also check which rule wins in the cascade.
The quoted format returns false
- Expected result
- The query checks the WOFF2 format.
- Cause
- font-format() evaluates the string "woff2" as false.
- Solution
- Write font-format(woff2) and use src hints when declaring the resource in @font-face.
The rule with and and or is ignored
- Expected result
- Alternative A can activate the block.
- Cause
- The prelude mixes two operators without grouping.
- Solution
- Write A or (B and C), replacing each letter with its condition.
The conditional stylesheet is ignored
- Expected result
- The import adds styles when the condition is true.
- Cause
- The @import rule appears after a style rule.
- Solution
- Move imports to the start of the stylesheet and check the support condition separately.
Support and compatibility
Check the status of @supports and each function separately. The result of named-feature() also depends on the name tested. To verify an effect, compare the API condition, the applied block, and the geometry or computed style of the scene.
Back to the @supports playground