[CSS Selector] E + F
Using '+' (plus sign), you can apply styles only to the immediately following sibling element of the specified element. Note that despite being called the "adjacent sibling selector," it does not apply to the preceding sibling element. It only applies to the next sibling element that follows. Also note that this does not work in IE6 or earlier.
Sample Code
h2 + p { color: red;} /* Applies only to the p element immediately following the h2 element. */
Browser Result
h2 + p { color: red;} /* Applies only to the p element immediately following the h2 element. */
<p>This is a p element. It comes before the h2, so it does not turn red.</p> <h2>This is an h2 element.</h2> <p>This is a p element.</p> <p>This is a p element.</p>
Browser Support
Desktop
Supported in all versions.
8 ○
7 ○
6 ×
2 and earlier ×Mobile
Android Browser
4.4+ ○
3 and earlier ×Same support as desktop version.
Same support as desktop version.
* Version information is based on MDN.
If you find any errors or copyright issues, please contact us.