The Next-Sibling Combinator
The plus combinator matches the single element immediately after another element that shares its parent.
Match the immediately following sibling and inspect what breaks adjacency.
In each dish card, the price comes straight after the dish name. The owner wants a little space between the name and whatever follows it. You do not have to label the element that follows; you can describe it by where it sits.
The rule
+means "the very next sibling": same parent, immediately after.
A + B matches a B that comes immediately after an A, with the same parent. Only one element can be "the next" after any A.
<main>
<section id="menu">
<h2>Today's menu</h2>
<article class="dish">
<h3>Masala omelette</h3>
<p class="price">₹180</p>
<p>Three eggs, green chilli and coriander.</p>
</article>
<article class="dish special">
<h3>Mango lassi</h3>
<p class="price">₹120</p>
<p>Thick, cold and only in summer.</p>
</article>
</section>
<section id="visit">
<h2>Visit us</h2>
<p>Open 8 am to 6 pm, every day.</p>
</section>
</main>h3 + p {
margin-top: 0.25rem;
}In each card the order is h3, p.price, p. The element straight after each h3 is the price paragraph, so h3 + p matches the two prices, not the descriptions.
More readings on this page:
h2 + articlematches the omelette's card, the first thing after "Today's menu". The lassi card comes after another article, not after theh2.article + articlematches the lassi's card.h2 + pmatches only the opening hours. In the menu section, theh2is followed by anarticle, not ap..price + pmatches the two descriptions.
Siblings share a parent. The h2 in #menu and the paragraphs inside the cards are not siblings, because the paragraphs have a different parent.
Like all combinators, + adds nothing to specificity: h3 + p is (0,0,2).