Использование селектора :only-of-type

Демонстрация работы селекторов :only-child и :only-of-type, адаптация примера из урока Dudley Storey, специально для сайта dejurka.ru

HTML

<div class="first">
    <h1>Заголовок</h1>
    <p>Текст…</p>
</div>
<div class="second">
    <h1>Заголовок</h1>
    <p>Текст…</p>
</div>

CSS

div.first p:only-child { color: red; }
div.second p:only-of-type { color: red; }