Skip to content

CSS Selectors

Is

About

The :is(selector list) pseudo-class function accepts a list of selectors as argument. It matches all elements that match any of the selectors passed as arguments.

The selector is currently not supported in Firefox.

Multiple elements

The selector :is(h1, h2, 3) + p matches all paragraphs that are preceded by an h1, h2 or h3 element. Without :is() you would have to repeat the same selector multiple times: h1 + p, h2 + p, h3 + p.

Invalid selectors

The :is() selector will ignore invalid selectors. In this example, the :is() selector will match all div elements. The div:invalid-selector selector is invalid, so it will be ignored. This is helpful when you want to use a selector that is not supported in all browsers.

Specificity

The :is() selector has some special specificity rules. The specificity of the selector is equal to the highest specificity of the selectors passed as arguments. For example, the specificity of :is(.some-class, h1) is equal to the specificity of .some-class, which is 010 because it has one class selector.