Easy Tutorial
❮ Css3 Pr Flex Wrap Sel Not ❯

CSS3 :only-child Selector

Complete CSS Selectors Reference

Example

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

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

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 specify the first browser version that fully supports the property.

Selector
:only-child 4.0 9.0 3.5 3.2 9.6

Complete CSS Selectors Reference

❮ Css3 Pr Flex Wrap Sel Not ❯