CSS :empty Pseudo-class

Definition and Usage

CSS :empty Pseudo-classes are used to match each element that has no child elements (including text nodes).

Tip:An element has child elements if it contains other elements, text, or whitespace between tags.

Example

Specify a light orange background color for empty elements with class="box":

box:empty {
  background-color: salmon;
}

Try It Yourself

CSS Syntax

:empty {
  css declarations;
}

Technical Details

Version: CSS3

Browser Support

The numbers in the table specify the first browser version to fully support the pseudo-class.

Chrome Edge Firefox Safari Opera
4.0 9.0 3.5 3.2 9.6