CSS: adjacent sibling selector (+)
Next-Sibling Combinator (Has Immediate Older Brother X)
aaa + bbb-
Match any bbb that immediately comes after aaa. (aaa and bbb are in the same level.)
Each expression can be compound selector.
/* match the b tag that comes immediately after span */ span+b {color:red;} matches the B:
<div> <span>A</span> <b>B</b> </div>
CSS, Selectors
simple selectors
- CSS: element selector (tag name)
- CSS: universal selector (* any tag)
- CSS: class selector
- CSS: ID selector
- CSS: attribute selector
- CSS: multiple attributes selector
selector list
relationship selectors (combinators)
- CSS: descendant selector (space)
- CSS: child selector (>)
- CSS: subsequent sibling selector (~)
- CSS: adjacent sibling selector (+)
special selector
- CSS: :root selector
- CSS: no child selector
- CSS: sibling selector
- CSS: pseudo-class selector (:)
- CSS: pseudo-element selector (::)
- CSS: negation selector (:not)
- CSS: is any of selector (:is, :where)
- CSS: :has descendant selector