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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.