selector

next-sibling — CSS reference

Targets B immediately after A among element siblings with the same parent. Text and comments do not interrupt the relationship.

Formal Syntax & Structure

css syntaxcss
A + B

Working Example

Example Snippetcss
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Selector lab</title><style>:where(.sample) { color: rgb(32, 32, 32); }h2 + p { color: rgb(0, 96, 80); }</style></head><body><h2>Title</h2> text <p id="a" class="sample">A</p><p id="b" class="sample">B</p></body></html>
CSS Reference