CSS3 Selectors: nth-of-type

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

nth-of-type can be useful should there be other sibling elements that we are targeting.

The example below targets only the 2nd paragraph of the <section> tag.

<!DOCTYPE html>
<head lang='en'>
    <meta charset='UTF-8'>
    <title>Codecrawl.com - HTML5</title>
        section p:nth-of-type(2) {
            color: blue;

        <h1>Rod Stewart</h1>

        <h4>Sing It For Us Rod</h4>
        <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: last-of-type
CSS3 Selectors: nth-last-of-type >>