CSS: descendant selector (space)

By Xah Lee. Date: . Last updated: .

Match Ancestor Tag (aka Descendant Combinator)

tag1 tag2

Match tag2 that is nested inside tag1 at any depth.

tag can be a simple selector or compound selector.

Can also be chained like this:

tag1 tag2 tag3

/* any span that's nested in div */
div span {
 color: red;
}
<div>
 <span>match</span>
 <p>
  <span>match</span>
</p>
</div>

CSS. Selectors

Selector types
Simple selectors
Combinators
Selector list
Nesting syntax
Special selector
Misc