CSS3 Selectors: Only-of-type

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

:only-of-type targets elements whose parent elements have no other children of the same type.

The <p> tag in <header> is targeted as it has only one <p> tag.

<!DOCTYPE html>
<head lang='en'>
    <meta charset='UTF-8'>
    <title>Codecrawl.com - HTML5</title>
        p:only-of-type {
            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: nth-last-of-type
CSS3 Selectors: Pseudo-class :empty >>