<div>
    <p>This is the only p element.</p>
    <span>This is a span.</span>
</div>

<div>
    <p>This is the first p element.</p>
    <p>This is the second p element.</p>
</div>
p:only-of-type {
    background-color: yellowgreen;
}
Rendered Output
:only-of-type {
    /* ... */
}
<div>
    <p>This is a paragraph element.</p>
</div>
<div>
    <p>This is a paragraph element.</p>
    <p>This is a paragraph element.</p>
</div>
p:only-of-type {
    background-color: yellowgreen;
}
Rendered Output
<style>
    .red-item:only-of-type {
        color: red;
        font-weight: bold;
    }
</style>
<div>
    <p>This is a paragraph element.</p>
    <p class="red-item">Expected to match, but it does not.</p>
    <p>This is a paragraph element.</p>
</div>
<!--
    * Did it select the only (sole) element of the .red-item type?
    * If so, that is incorrect.
    *
    * :only-of-type selects the sole element among sibling elements of the same tag name.
    *
    * .red-item:only-of-type has two parts:
    * => .red-item: The element with the class attribute value 'red-item' has a <p> tag name.
    * => "Type" refers to the tag name type.
    * => In this case, the specific type is <p>.
    * => The sole <p> element must also have the 'red-item' class value to be selected.
    * => Therefore, in this example, there is no matching element.
-->
Rendered Output No elements are matched by the .red-item:only-of-type selector.