The element + element selector — also called the adjacent sibling combinator — targets an element only when it is the very next sibling after another element. It is perfect for precise spacing and typography tweaks.
01
+ combinator
Next sibling only.
02
Syntax
el1 + el2
03
Headings
Style intro paragraphs.
04
Forms
Label-to-input spacing.
05
vs ~
One vs all siblings.
06
Clean CSS
Avoid extra classes.
Fundamentals
Introduction
The element + element selector in CSS is used to select an element that is directly preceded by another specified element. Both elements must share the same parent and sit next to each other in the HTML.
This combinator is useful when you want to style one specific neighbor — for example, the first paragraph after a heading — without affecting other similar elements further down the page.
Definition and Usage
Write the first selector, a plus sign (+), then the second selector. The rule applies only when the second element is the immediate next sibling of the first. If any other element sits between them, the selector does not match.
💡
Beginner Tip
Think of + as “the very next brother or sister element.” If you need all following siblings, use the general sibling combinator ~ instead.
Foundation
📝 Syntax
The signature of the adjacent sibling selector is:
The adjacent sibling selector shines when the relationship is “right after”:
Intro paragraphs — Style the first paragraph after a heading differently from body text.
Form fields — Add margin between a label and its input when they are siblings.
Stacked components — Use .item + .item for gap between consecutive cards or list rows.
Toolbar buttons — Add left margin to a button that follows another button.
Figure captions — Target a caption element immediately after an image.
Preview
👀 Live Preview
Only the first paragraph after the heading is styled by h3 + p:
Section Title
This paragraph is adjacent to the heading.
This paragraph is not adjacent to the heading.
Hands-On
Examples Gallery
Practice the + combinator with headings, forms, cards, and sibling comparisons.
📜 Core Patterns
Target the single element that immediately follows another sibling.
Example 1 — Heading and adjacent paragraph
Style only the paragraph that directly follows an <h2>.
heading-paragraph.html
<style>h2 + p{color:#2563eb;font-weight:600;margin-top:0;}</style><h2>Section Title</h2><p>This paragraph is adjacent to the heading.</p><p>This paragraph is not adjacent to the heading.</p>
The first <p> is the immediate next sibling of <h2>. The second paragraph has a different preceding sibling (the first paragraph), so it is not matched.
Example 2 — Label and input spacing
Add top margin to an input that directly follows its label.
The first card has no top margin from this rule. Each card that immediately follows another card gets spacing — a clean alternative to margin-bottom on every item.
Example 4 — Adjacent (+) vs general (~) sibling
See why + matches one sibling while ~ would match all following siblings.
plus-vs-tilde.css
/* Only the first p after h2 */h2 + p{color:#2563eb;}/* All p siblings after h2 */h2 ~ p{color:#16a34a;}
h2 + p stops at the first paragraph. If you need every paragraph after the heading, switch to h2 ~ p.
Watch Out
⚠️ Common Pitfalls
Elements in between — A comment, wrapper, or extra tag between siblings breaks the match. The second element must be directly next in the DOM.
Only one sibling — + never selects multiple elements. Use ~ for that.
Wrong parent — Siblings must share the same parent. Cousins or nested elements do not qualify.
Markup structure — If your label wraps the input, label + input will not work; adjust HTML or use a different selector.
A11y
♿ Accessibility
Keep semantic HTML — Combinators style structure; they do not replace proper heading levels or label associations.
Do not hide content with + alone — If only the adjacent element is styled differently, ensure meaning is still clear to screen reader users.
Focus order — When styling label + input, keep logical tab order and visible focus styles on inputs.
Color contrast — Highlighted intro text must still meet contrast guidelines.
🧠 How element + element Works
1
Browser reads the DOM tree
Elements are grouped by parent. Siblings are children listed one after another.
Structure
2
First selector finds anchors
Every matching element1 becomes a starting point.
Match
3
+ checks the next sibling
If the very next sibling matches element2, styles apply.
Combinator
=
✅
Precise styling
Only the intended neighbor element is affected.
Compatibility
Browser Compatibility
The adjacent sibling combinator is supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera.
✓ Universal · All browsers
Reliable combinator support
The + selector has been supported across browsers for many years and works consistently on desktop and mobile.
99%Browser support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions
Full support
OperaAll versions
Full support
+ adjacent sibling combinator99% supported
Bottom line: Safe to use element + element in any modern project.
Wrap Up
Conclusion
The element + element adjacent sibling selector is a powerful way to style elements based on their immediate neighbor in the DOM. It keeps CSS focused and avoids sprinkling extra classes on every second element.
Use + when you need exactly one next sibling. Reach for ~ when you need every following sibling. Together, these combinators help you write cleaner, more maintainable stylesheets.
The adjacent sibling selector (element1 + element2) selects element2 only when it immediately follows element1 as the next sibling in the HTML.
The + combinator matches only the single next sibling. The ~ general sibling combinator matches all following siblings at the same level.
Spaces around the + sign are required for readability and valid parsing. The two elements must still be direct siblings with no other elements between them in the DOM.
Yes. Selectors like .intro + p or #title + span work the same way — the second element must be the immediate next sibling of the first.
Yes. All modern browsers support the + combinator. It has been part of CSS for many years.