concept

Supports selector query — CSS reference

The selector() supports function tests whether a selector is accepted, not whether any element currently matches it. Keep baseline selectors outside the conditional block when content must remain accessible.

Formal Syntax & Structure

css syntaxcss
@supports selector(:has(*)) { /* enhancement */ }

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>supports selector query</title><style>body{margin:0}#a{padding:8px;background:rgb(232,237,241);color:rgb(0,0,0);box-sizing:border-box}@supports selector(:has(*)) {#a{color:rgb(0,100,0)}}</style><body><main id="a">Resize the viewport to explore this example.</main></body></html>
CSS Reference