CSS: adjacent sibling selector (+)

By Xah Lee. Date: . Last updated: .

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
selector list
relationship selectors (combinators)
special selector
misc