Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

:is() — matching any selector

The :is() pseudo-class groups alternative selectors. It takes the highest argument specificity, including arguments that do not match.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

:is(<forgiving-selector-list>)

:is() matches an element matching at least one selector in its comma-separated list. Arguments can contain combinators.

The list tolerates invalid selectors: it discards them, preserving valid ones. An empty list matches nothing. Pseudo-elements inside :is() are forbidden.

Specificity comes from the most specific valid argument, regardless of matching. In the example, :is(.note, #special) has specificity (1,0,0) even for Alpha. In contrast, :where() always contributes zero specificity.

Examples

<!doctype html>
<meta charset="utf-8">
<title>:is() specificity</title>
<style>
  :is(.note, #special) { color: green; }
  .note { color: red; }
</style>
<p class="note">Alpha</p>
<p id="special">Beta</p>

Result

Alpha: rgb(0, 128, 0)
Beta: rgb(0, 128, 0)

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources