HTML and CSS Reference
In-Depth Information
Applies to:
Any element
Matches an element that is the only child element of its parent element. A common use case
for this selector is to remove the border from any linked image, assuming that said image is
the only element in the link. Note that an element can be selected by :only-child even if it
has its own child or children. It must only be the only child of its parent.
a img:only-child {border: 0;}
table div:only-child {margin: 5px;}
Search WWH ::

Custom Search