Learn more about selectors in the W3 CSS spec, or continue reading for a summary:
Selection of Immediate Child
The >
selector is used to target the immediate child element. In the example li > a
, any <a>
tag that is directly nested inside an <li>
element will be selected.
For instance, this anchor element would be chosen:
<ul>
<li><a href="#">An anchor</a></li>
</ul>
Adjacent Sibling Selection
The +
selector represents the adjacent sibling relationship. In the case of div + span
, any <span>
element immediately following a <div>
within the same parent container will match the rule.
Here's an example where the span element would be targeted:
<article>
<div>A preceding div element</div>
<span>This span would be selected</span>
</article>