Skip to content

CSS Selectors

Where

About

The :where(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 :where(h1, h2, 3) + p matches all paragraphs that are preceded by an h1, h2 or h3 element. Without :where() you would have to repeat the same selector multiple times: h1 + p, h2 + p, h3 + p.

Invalid selectors

The :where() pseudo-class will ignore invalid selectors. In this example, the :where() selector will match all div elements. The :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 :where() pseudo-class has some special specificity rules. The specificity of the selector is always 0, regardless of the specificity of the selectors passed as argument.