Support0

CSS @supports Playground

Check support for declarations, selectors, at-rules, named features, and fonts. Combine conditions and see which styles the browser applies.

Ask AI

CSS @supports Playground

Response generated with openai/gpt-5.4-nano. AI can make mistakes. Always review the result.
Item A
Item B
Condition
(display: grid)
CSS.supports()
Awaiting result
@supports block
Awaiting result
Computed style
Awaiting result
HTML
<div class="supports-grid">
  <div>Item A</div>
  <div>Item B</div>
</div>
Tailwind CSS
Examples for Tailwind CSS 4.3 with the default theme. Custom values keep arbitrary classes when there is no equivalent utility. Changing the theme can change utility values.
<div class="block *:border *:p-[0.5em] *:wrap-anywhere supports-[display:grid]:grid supports-[display:grid]:grid-cols-2">
  <div>Item A</div>
  <div>Item B</div>
</div>
CSS
.supports-grid {
  display: block;
}

.supports-grid > div {
  border: 1px solid;
  padding: 0.5em;
  overflow-wrap: anywhere;
}

@supports (display: grid) {
  .supports-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

The two cells share a row when (display: grid) is true.
Block flow with a Grid enhancement
<div class="supports-grid">
  <div>Item A</div>
  <div>Item B</div>
</div>
.supports-grid {
  display: block;
}

.supports-grid > div {
  border: 1px solid;
  padding: 0.5em;
  overflow-wrap: anywhere;
}

@supports (display: grid) {
  .supports-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

Made-up display value

Use the HTML from the Grid example to see block flow with this false condition.

Made-up display value
CSS
.supports-grid {
  display: block;
}

.supports-grid > div {
  border: 1px solid;
  padding: 0.5em;
  overflow-wrap: anywhere;
}

@supports (display: baseline-lab-invalid) {
  .supports-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

With :has() support and the .item child present, the card has a solid outline.
Outline for a card with a direct child
<div class="supports-card">
  <div>Card</div>
  <div class="item">Direct child</div>
</div>
.supports-card {
  outline: 2px dashed;
  outline-offset: -2px;
  padding: 0.5em;
}

@supports selector(:has(> .item)) {
  .supports-card:has(> .item) {
    outline-style: solid;
  }
}

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

The border frames 12px of base padding, or 24px with the active block and a valid registration.
Spacing from a registered property
<div class="supports-spacing">Card spacing</div>
@property --example-spacing {
  syntax: "<length>";
  inherits: false;
  initial-value: 24px;
}

.supports-spacing {
  border: 2px solid;
  padding-block: 0.5em;
  padding-inline: 12px;
}

@supports at-rule(@property) {
  .supports-spacing {
    padding-inline: var(--example-spacing, 12px);
  }
}

Controls for at-rule() and a more specific test

Controls for at-rule() and a more specific test
JavaScript
for (const condition of [
  'at-rule(@media)',
  'at-rule(@container)',
  '(container-type: scroll-state)',
  'at-rule(@function)',
  'at-rule(@charset)',
  'at-rule(@container style(--test: 1))',
  'at-rule(@baseline-lab-unknown)',
]) {
  console.log(condition, CSS.supports(condition));
}

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.

In the tests, all three engines accepted the direct declaration. Chrome computed scroll / clip and reached (30, 0). Firefox and WebKit computed scroll / hidden and reached (30, 30) with programmatic scrolling.
Guarded scrolling and a direct declaration
<div class="guarded">
  <p>With named-feature()</p>
  <div class="supports-scroll" tabindex="0" role="region" aria-label="With named-feature()">
    <div class="supports-scroll-content">
      <div>Origin</div>
      <div>X axis</div>
      <div>Y axis</div>
      <div>X and Y axes</div>
    </div>
  </div>
</div>

<div class="direct">
  <p>With direct overflow</p>
  <div class="supports-scroll" tabindex="0" role="region" aria-label="With direct overflow">
    <div class="supports-scroll-content">
      <div>Origin</div>
      <div>X axis</div>
      <div>Y axis</div>
      <div>X and Y axes</div>
    </div>
  </div>
</div>
.supports-scroll {
  box-sizing: border-box;
  inline-size: min(100%, 14rem);
  block-size: 6rem;
  border: 1px solid;
  overflow: scroll;
}

.supports-scroll > .supports-scroll-content {
  inline-size: 200%;
  block-size: 200%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.supports-scroll > .supports-scroll-content > div {
  border: 1px solid;
  padding: 0.5em;
  overflow-wrap: anywhere;
}

.direct > .supports-scroll {
  overflow: scroll clip;
}

@supports named-feature(single-axis-scroll-container) {
  .guarded > .supports-scroll {
    overflow: scroll clip;
  }
}

Moving the anchor

Checking the box moves the anchor by 48px. Watch whether the positioned element follows it. Both labels stay in flow when anchor declarations are unavailable.
Moving the anchor
<div class="anchor-example">
  <input id="move-anchor" type="checkbox">
  <label for="move-anchor">Move the anchor</label>
  <p class="anchor">Anchor</p>
  <p class="attached">Positioned element</p>
</div>
.anchor-example {
  position: relative;
}

.anchor {
  inline-size: fit-content;
  outline: 1px solid;
}

#move-anchor:checked ~ .anchor {
  translate: 48px;
}

@supports (anchor-name: --example-anchor) and (inset-inline-start: anchor(left)) {
  .anchor-example {
    padding-block-end: 4em;
  }

  .anchor {
    anchor-name: --example-anchor;
  }

  .attached {
    position: absolute;
    position-anchor: --example-anchor;
    inset-inline-start: anchor(left);
    inset-block-start: anchor(bottom);
    margin: 0;
  }
}

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

The solid border shows the active font-tech(variations) branch.
Font variations
<div class="supports-sample">Card border</div>
.supports-sample {
  border: 2px dashed;
  padding: 0.5em;
}

@supports font-tech(variations) {
  .supports-sample {
    border-style: solid;
  }
}

WOFF2 format

Reuse the card HTML and query the format with the unquoted keyword.

WOFF2 format
CSS
.supports-sample {
  border: 2px dashed;
  padding: 0.5em;
}

@supports font-format(woff2) {
  .supports-sample {
    border-style: solid;
  }
}

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

Grouped operators
<div class="supports-sample">Card border</div>
.supports-sample {
  border: 2px dashed;
  padding: 0.5em;
}

@supports (display: grid) or (selector(:has(> .item)) and (display: baseline-lab-invalid)) {
  .supports-sample {
    border-style: solid;
  }
}

The same operators without grouping

Use the same HTML. The invalid prelude leaves the base style in place.

The same operators without grouping
CSS
.supports-sample {
  border: 2px dashed;
  padding: 0.5em;
}

@supports (display: grid) or selector(:has(> .item)) and (display: baseline-lab-invalid) {
  .supports-sample {
    border-style: solid;
  }
}

Negating an unknown function

With the same HTML, not inverts the false result of the extensible condition.

Negating an unknown function
CSS
.supports-sample {
  border: 2px dashed;
  padding: 0.5em;
}

@supports not future-feature(value) {
  .supports-sample {
    border-style: solid;
  }
}

Container size inside a support query

Container size inside a support query
<div class="supports-container">
  <div class="supports-spacing">Card spacing</div>
</div>
.supports-container {
  container-type: inline-size;
  inline-size: min(100%, 14rem);
}

.supports-container > .supports-spacing {
  border: 2px solid;
  padding-block: 0.5em;
  padding-inline: 12px;
}

@supports (display: grid) {
  @container (inline-size >= 12rem) {
    .supports-container > .supports-spacing {
      padding-inline: 24px;
    }
  }
}
.supports-container {
  container-type: inline-size;
  inline-size: min(100%, 14rem);
}

.supports-container > .supports-spacing {
  border: 2px solid;
  padding-block: 0.5em;
  padding-inline: 12px;

  @supports (display: grid) {
    @container (inline-size >= 12rem) {
      padding-inline: 24px;
    }
  }
}

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

Import base and enhancement styles
@import "base.css";
@import "grid.css" supports(display: grid);
<link rel="stylesheet" href="main.css">

<div class="supports-grid">
  <div>Item A</div>
  <div>Item B</div>
</div>
.supports-grid {
  display: block;
}
.supports-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

The two CSS.supports() signatures
JavaScript
console.log(CSS.supports('display', 'grid'));
console.log(CSS.supports('selector(:has(> .item))'));
console.log(CSS.supports('(display: grid) or (selector(:has(> .item)) and (display: baseline-lab-invalid))'));

Choosing padding with if()

Choosing padding with if()
CSS
.card {
  padding-inline: 12px;
  padding-inline: if(
    supports(display: grid): 24px;
    else: 12px
  );
}
Try supports() inside 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 environment query
.panel {
  padding-block-start: 1rem;
}

@supports env(safe-area-inset-top) {
  .panel {
    padding-block-start: max(1rem, env(safe-area-inset-top));
  }
}
console.log(CSS.supports('env(safe-area-inset-top)'));
console.log(CSS.supports('padding-top', 'env(safe-area-inset-top)'));

Draft named condition

Draft named condition
<div class="supports-grid">
  <div>Item A</div>
  <div>Item B</div>
</div>
.supports-grid {
  display: block;
}

@supports-condition --example-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@supports (--example-grid) {
  .supports-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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