CSS: child selector (>)
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
- CSS: type selector (tag name)
- CSS: universal selector (* any tag)
- CSS: class selector (.x)
- CSS: ID selector (#)
- CSS: attribute selector ([x])
Combinators
- CSS: descendant selector (space)
- CSS: child selector (>)
- CSS: adjacent sibling selector (+)
- CSS: subsequent sibling selector (~)
Selector list
Nesting syntax
Special selector
- CSS: :root selector
- CSS: no child selector
- CSS: first child, last child, only child selectors
- CSS: nth-child selector
- CSS: nth-child arg of selector
- CSS: nth-of-type selector
- CSS: pseudo-class selector (:)
- CSS: pseudo-element selector (::)
- CSS: :not negation selector
- CSS: :has descendant selector