CSS3 :empty Selector

Example

Specify a background color for empty p elements:

p:empty
{
background:#ff0000;
}

Try it yourself »

Definition and Usage

The :empty selector matches every element that has no children (including text nodes).


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The :root selector is supported in all major browsers, except Internet Explorer.