Abakada: Back to Basics > Language References > CSS Properties > Pseudo-Classes > empty Pseudo-class
Represents an element that has no children.
selector:empty { property: value; }
property |
Any valid CSS property. |
value |
Any of the range of values available to the corresponding property. |
The :empty pseudo-class applies styles to elements that have no children.
The syntax for using the :empty pseudo-class is straightforward. A selector immediately precedes the pseudo-class.
For example, to change the background color of empty elements on a page.
div:empty { background-color: beige }
The following demonstrates use of the :empty pseudo-class in an embedded stylesheet to set the style of empty elements on a page.
:disabled :enabled