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>
<head lang='en'>
    <meta charset='UTF-8'>
    <title>Codecrawl.com - HTML5</title>
        header p:first-of-type {
            color: blue;

        <h1>Rod Stewart</h1>

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

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


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

Leave a comment

Leave a Reply