:only-child
:only-child – pseudo-class
The :only-child
pseudo-class selects element that is the only child of its parent.
Syntax
element:only-child {
/* ... */
}
:only-child {
/* ... */
}
The :only-child
selector is the same as :first-child:last-child
or nth-child(1):nth-last-child(1)
. The :only-child
has lower specificity.
See the Pen :only-child by majadc (@majadc) on CodePen.