Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

Selector list

The list A, B joins selectors with a comma so that one rule covers elements matching either selector.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

A, B { property: value; }

In A, B, A and B stand for selectors. The comma means an alternative: match an element satisfying at least one selector. It requires no relationship between elements; in contrast, A B is a descendant selector.

Specificities are not added together. For a given element, the highest specificity among the matching selectors in the list applies.

An invalid selector invalidates the entire ordinary list, so the rule is not applied. Forgiving lists in :is() and :where() discard invalid entries; they also have their own specificity rules.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Selector list</title>
<style>
.notice, #special {
  outline: 2px solid blue;
}
</style>
<p class="notice">Alpha</p>
<p id="special">Beta</p>
<p>Gamma</p>
</html>

Result

Alpha: blue outline.
Beta: blue outline.
Gamma: no outline.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources