CSS: child selector (>)

By Xah Lee. Date: . Last updated: .

Match a Parent Tag (aka Child Combinator)

tag1 > tag2

Match tag2 that is a direct child of tag1.

tag can be a simple selector or compound selector.

Can also be chained like this:

a > b > c

/* any span that's direct child of div */
div > span {
 color: red;
}
<div>
 <span>match</span>
</div>

<div>
 <p>
  <span>no</span>
</p>
</div>

CSS. Selectors

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