CSS3 :only-child selector
Complete CSS Selector Reference Manual
Example
Match p elements that are the only child of their parent:
p
:only-child
{
background:
#ff0000
;
}
Try it »
Definition and Usage
:only-child selector matches an element that is the only child of its parent.
Browser support
The numbers in the table indicate the first browser version that supports this property.
| Selector | |||||
|---|---|---|---|---|---|
| :only-child | 4.0 | 9.0 | 3.5 | 3.2 | 9.6 |