combinator
Adjacent Sibling Combinator
Matches element B when it is the element immediately following A and both share the same parent. It is often used to add spacing between consecutive elements.
A + B Example
h2 + p { margin-top: 0; } /* Paragraph right after an <h2> */ ✓ Matches
- <h2>T</h2><p>Right after</p>
- <label>Name</label><input>
- <li>A</li><li>B</li> the second li matches li + li
✗ Does not match
- <h2>T</h2><div></div><p>Not adjacent</p> since a div separates them
- <p>Standalone</p> with no preceding h2 sibling
Browser support
Universal support in all browsers since CSS2.