SyntaxStudy
Sign Up
CSS :is() and :where() Pseudo-Classes
CSS Intermediate 5 min read

:is() and :where() Pseudo-Classes

:is() and :where()

:is() matches if the element matches any selector in the list. :where() is identical but has zero specificity, making it easy to override.

Example
/* Without :is() — repetitive */
h1 a, h2 a, h3 a, h4 a { color: inherit; }

/* With :is() — cleaner */
:is(h1, h2, h3, h4) a { color: inherit; }

/* :where() has zero specificity — easy to override */
:where(h1, h2, h3) { margin-top: 1.5em; }

/* This simple class overrides the :where() above */
.no-margin { margin-top: 0; }
Pro Tip

Use :where() for base/reset styles that should be easy to override; use :is() when you want the selector's specificity.