CSS @supports-condition At-Rule

A supports condition is a CSS feature-test expression used by @supports and CSS.supports().

Despite this reference entry’s filename, @supports-condition is not a standalone CSS at-rule. Use the real @supports syntax for feature queries.

Syntax

@supports (display: grid) and (gap: 1rem) {
  .layout {
    display: grid;
    gap: 1rem;
  }
}

A supports condition is the expression following @supports. There is no independent CSS at-rule named @supports-condition.

How Supports Conditions Work

A supports condition evaluates whether a browser recognizes the tested CSS feature syntax. If the condition is true, declarations inside the surrounding @supports block participate in the cascade.

A positive test does not guarantee that every detail of a feature renders identically across browsers.

Not a Standalone At-Rule

/* Valid */
@supports (display: grid) {
  .layout { display: grid; }
}
/* Invalid: no @supports-condition at-rule */
@supports-condition (display: grid) {
  .layout { display: grid; }
}

Use @supports to wrap a condition. The term supports condition describes its grammar, not a separately recognized rule.

Logical Operators

@supports (display: grid) and (gap: 1rem) {
  .layout { display: grid; gap: 1rem; }
}
@supports not (display: grid) {
  .layout { display: block; }
}
@supports (display: grid) or (display: flex) {
  .layout { max-width: 60rem; }
}

Use and when all tests must succeed, or when at least one must succeed, and not to negate a condition. Parentheses make individual tests clear.

Testing Selectors

@supports selector(:has(> img)) {
  .card:has(> img) {
    padding-top: 1rem;
  }
}

The selector() function tests whether the browser recognizes a selector. It does not test whether any element currently matches that selector.

JavaScript Equivalent

CSS.supports("display", "grid");
CSS.supports("(display: grid) and (gap: 1rem)");
CSS.supports("selector(:has(> img))");

CSS.supports() returns a boolean for a declaration or a complete condition string. The same underlying feature checks can inform progressive enhancement in scripts.

Progressive Enhancement

.layout {
  display: block;
}
@supports (display: grid) {
  .layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
}

Define a usable base style first, then enhance it inside the feature query. This allows older browsers to retain a readable layout.

Supports Condition Example

The following layout uses Grid when supported and otherwise keeps a simple block layout.

HTML

<div class="supports-demo-layout">
  <div>First item</div>
  <div>Second item</div>
</div>

CSS

.supports-demo-layout {
  display: block;
}
@supports (display: grid) {
  .supports-demo-layout {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}
Browser Result
First item
Second item

The Browser Result uses the feature query shown above. The two items appear in columns when Grid is supported.

Browser Support

The @supports at-rule is widely supported in modern browsers. The result of any particular condition depends on support for the tested feature. Consult Can I Use? for individual features.

Specifications

Supports conditions are defined by CSS Conditional Rules Module Level 3.

CSS Conditional Rules Module Level 3