CSS3 :only-of-type Selector

Example

Specify a background color for every p element that is the only child of its type, of its parent:

p:only-of-type
{
background:#ff0000;
}

Try it yourself »

Definition and Usage

The :only-of-type selector matches every element that is the only child of its type, of its parent.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The :only-of-type selector is supported in all major browsers, except Internet Explorer.