Combinators

Combinators are used to select more complex structures. They can help target specific elements or groups of elements that would be difficult to target otherwise.

Descendant combinator

This selector specifies that an element must be contained by another element.

The combinator is the whitespace character. We are explicitly defining it here so that it is clear:

selector-a selector-b

Description

The two or more statements used in this selector can be any valid selector statement. For example, the first could be a class selector followed by a type selector. The distance between the selectors does not matter. Each intermediate element will not have to be listed for the selector to work.

The combinator can be stacked. Each statement will have a ...

Get Web Developer's Reference Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.