CSS3 Selectors: first-of-type

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

The element that is the first element of its type in a given parent element.

We use this to target the first paragraph in a header.
 
Codecrawl.com – HTML5

<!DOCTYPE html>
<html>
<head lang='en'>
    <meta charset='UTF-8'>
    <title>Codecrawl.com - HTML5</title>
    <style>
        header p:first-of-type {
            color: blue;
        }
    </style>
</head>
<body>

<article>
    <header>
        <h1>Rod Stewart</h1>

        <p>17.05.2014</p>
    </header>
    <section>
        <p>Rod Stewart is one of the best-selling music artists of all time</p>

        <p>Having sold over
            100 million records worldwide.</p>
    </section>
</article>

</body>
</html>

Series Navigation<< CSS3 Selectors: Only-child
CSS3 Selectors: last-of-type >>