Skip to content

Commit 4af179d

Browse files
authored
Clarified the text of the adjacent-sibling combinator section of css/building_blocks/selectors/combinators/index.html (#2546)
1 parent 2fd538c commit 4af179d

File tree

1 file changed

+2
-2
lines changed
  • files/en-us/learn/css/building_blocks/selectors/combinators

1 file changed

+2
-2
lines changed

files/en-us/learn/css/building_blocks/selectors/combinators/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ <h2 id="Child_combinator">Child combinator</h2>
4848

4949
<h2 id="Adjacent_sibling_combinator">Adjacent sibling combinator</h2>
5050

51-
<p>The adjacent sibling selector (<code>+</code>) is used to select something if it is right next to another element at the same level of the hierarchy. For example, to select all <code>&lt;img&gt;</code> elements that come right after <code>&lt;p&gt;</code> elements:</p>
51+
<p>The adjacent sibling selector (<code>+</code>) is placed between two CSS selectors. It matches only those elements matched by the second selector that are the next sibling element of the first selector. For example, to select all <code>&lt;img&gt;</code> elements that are immediately preceded by a <code>&lt;p&gt;</code> element:</p>
5252

5353
<pre class="brush: css">p + img</pre>
5454

55-
<p>A common use case is to do something with a paragraph that follows a heading, as in my example below. Here we are looking for a paragraph which is directly adjacent to an <code>&lt;h1&gt;</code>, and styling it.</p>
55+
<p>A common use case is to do something with a paragraph that follows a heading, as in the example below. In that example, we are looking for any paragraph which shares a parent element with an <code>&lt;h1&gt;</code>, and immediately follows that <code>&lt;h1&gt;</code>.</p>
5656

5757
<p>If you insert some other element such as a <code>&lt;h2&gt;</code> in between the <code>&lt;h1&gt;</code> and the <code>&lt;p&gt;</code>, you will find that the paragraph is no longer matched by the selector and so does not get the background and foreground color applied when the element is adjacent.</p>
5858

0 commit comments

Comments
 (0)