CSS3 Selectors: nth-last-of-type

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

If you notice, the following setup will actually target the first paragraph of the <section> tag.

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

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

        <p>17.05.2014</p>
    </header>
    <section>
        <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>
    </section>
</article>

</body>
</html>

Series Navigation<< CSS3 Selectors: nth-of-type
CSS3 Selectors: Only-of-type >>

Leave a comment

Leave a Reply