:where()
Works like `:is()`, but always has zero specificity.
Syntax
:where(list) { … }Parameters
| Parameter | Type | Description |
|---|---|---|
| list | selectors | Selectors 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
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.