HTML and CSS Reference
In-Depth Information
Name
:only-of-type
Applies to:
Any element
Description:
Matches an element that is the only child element of its type to its parent element. Note that
an element can be selected by
:only-of-type
even if it has its own child or children of its
own type (such as
div
s within a
div
). It must only be the only child of its type to its parent.
Examples:
p em:only-of-type {font-weight: bold;}
section article:only-of-type {margin: 2em 0 3em;}