CSS3 :only-childSelectors

Complete CSS Selector Reference Manual

Example

Matches p elements that are the only child of their parent element:

p:only-child { background:#ff0000; }

Try it Yourself »

Definition and Usage

The :only-child selector matches elements that are the only child of their parent element.


Browser Support

The numbers in the table indicate the first browser version number that supports the property.

Selectors
:only-child 4.0 9.0 3.5 3.2 9.6

Complete CSS Selector Reference Manual

other extensions