Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

:is()

Matches an element that matches any selector in the list — a way to shorten long selector lists.

Syntax

:is(list) { … }

Parameters

ParameterTypeDescription
listselectorsSelectors separated by commas; an invalid one is skipped, not the whole rule.

Examples

One rule instead of four combinations:

<style>
  :is(article, aside) :is(h3, h4) { color: darkorange; }
</style>
 
<article><h3>Article heading</h3></article>
<aside><h4>Sidebar heading</h4></aside>
<h3>An ordinary heading</h3>

Notes

The specificity of :is() is that of its strongest argument: :is(#id, p) weighs as much as an id. If you need zero specificity, use :where().

See also

  • :where() — Works like `:is()`, but always has zero specificity.
  • A, B — A selector list: one rule for several selectors separated by commas.
  • :not() — Matches elements that do not match any of the selectors in the brackets.

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.