Syntax
:is(selector-list)
:where(selector-list)Examples
Reducing Repetition with :is()
Combining what would otherwise be several separate selectors.
/* Without :is() */
header a:hover, main a:hover, footer a:hover { color: blue; }
/* With :is() - equivalent, more concise */
:is(header, main, footer) a:hover { color: blue; }The Specificity Difference
Why :where() is preferred for low-priority base styles.
/* :is() takes on the highest specificity among its arguments */
:is(#sidebar, .content) p { color: gray; } /* behaves like #sidebar specificity */
/* :where() always contributes ZERO specificity - trivially overridable */
:where(#sidebar, .content) p { color: gray; } /* easy for any other rule to override */Parameters and values
- :is() (pseudo-class): Matches any selector in the list, uses highest specificity among them
- :where() (pseudo-class): Matches any selector in the list, always contributes zero specificity
Best practices
- Use :is() to shorten repetitive selector lists that share a common descendant pattern
- Use :where() specifically for reset styles, base component styles, or CSS you expect (and want) other rules to easily override
- Remember :where() zero-specificity is a genuine tool for library/design-system authors, so consumers can override defaults without fighting specificity
- Both accept complex selector lists, including combinators, giving significant power in a compact syntax
At a glance
- Purpose
- Presentation and layout
- File extension
- .css
- Runs in
- Web browsers
- Usually used with
- HTML and JavaScript
Specifications & further reading
Related CSS documentation
Basic Selectors
CSS selectors target elements to style. Type selectors match by tag name, class selectors (.name) match elements with that class, ID selectors (#name) match a single unique element, and the universal selector (*) matches everything. Classes are the most commonly used selector for reusable styling.Combinators
Combinators define relationships between selectors. The descendant combinator (space) matches any nested element. The child combinator (>) matches only direct children. The adjacent sibling combinator (+) matches the very next sibling. The general sibling combinator (~) matches all following siblings.Attribute Selectors
Attribute selectors target elements based on the presence or value of an HTML attribute, using square bracket syntax. They support several matching modes beyond exact equality, including starts-with, ends-with, and contains, making them powerful for targeting elements without needing extra classes.:has() - The Parent Selector
:has() matches an element if any of the selectors passed to it match something within it - effectively letting you style a parent based on its children or descendants, something CSS could never do natively before. It has broad, mainstream browser support as of 2026 and is safe to use in production.
CSS selectors target elements to style. Type selectors match by tag name, class selectors (.name) match elements with that class, ID selectors (#name) match a single unique element, and the universal selector (*) matches everything. Classes are the most commonly used selector for reusable styling.Combinators
Combinators define relationships between selectors. The descendant combinator (space) matches any nested element. The child combinator (>) matches only direct children. The adjacent sibling combinator (+) matches the very next sibling. The general sibling combinator (~) matches all following siblings.Attribute Selectors
Attribute selectors target elements based on the presence or value of an HTML attribute, using square bracket syntax. They support several matching modes beyond exact equality, including starts-with, ends-with, and contains, making them powerful for targeting elements without needing extra classes.:has() - The Parent Selector
:has() matches an element if any of the selectors passed to it match something within it - effectively letting you style a parent based on its children or descendants, something CSS could never do natively before. It has broad, mainstream browser support as of 2026 and is safe to use in production.