CSS3 Selectors: The + selector

This entry is part 9 of 40 in the series CSS3 Selectors

Here in this example, we use h2 + p.

This is an adjacent sibling combinator.

It selects an element <p> immediately preceded by a <h2> element.

<!DOCTYPE html>
<head lang='en'>
    <meta charset='UTF-8'>
        h2 + p {
            font-family: sans-serif;
            color: blue;
            font-size: 125%;
    <h1>American Music</h1>

    <p>The different types of music genre in America.</p><!-- Child combinator targets this paragraph -->

        <p>Taylor Swift</p><!-- Adjacent sibling combinator targets this paragraph -->
        <p>Carrie Underwood</p>
    <h1>Hard rock and metal</h1>

    <p> Nirvana has come to be regarded as one of the most influential and important rock bands of the modern era.</p>
    <!-- Child combinator targets this paragraph -->

Series Navigation<< CSS3 Selectors: The descendant selector
CSS3 Selectors: The ~ selector >>