Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

:where()

Works like `:is()`, but always has zero specificity.

Syntax

:where(list) { … }

Parameters

ParameterTypeDescription
listselectorsSelectors separated by commas.

Examples

:where(.card) p weighs as much as p, so the later rule wins:

<style>
  :where(.card) p { color: gray; }
  p { color: crimson; }
</style>
 
<div class="card"><p>The plain p rule wins because :where() adds nothing.</p></div>

Notes

:where() is handy for base styles and libraries: whoever uses them can override any rule with a simple selector.

See also

  • :is() — Matches an element that matches any selector in the list — a way to shorten long selector lists.
  • @layer — Groups styles into cascade layers: a later layer wins regardless of specificity.

In the tutorial

  • Modern selectors — The :is(), :where(), :not() with a list and :has() selectors — how to shorten long selectors and pick a parent by its content.

Thanks for reading!

Donate to the site — we work hard for you.