Which CSS pseudo-class selects elements that have no children?

The story behind the answer

The CSS pseudo-class `:empty` selects an element that has no children, including no text nodes.

It is useful for styling containers whose markup contains nothing at all—for example, hiding an empty message area or applying a placeholder style before content is inserted. Whitespace can matter: a line break or space in the HTML may create a text node, meaning the element is not considered empty under the traditional definition.

`:empty` is not the same as `:nth-child(0)`, which does not identify empty elements, and `:hidden` is not a standard CSS pseudo-class. The newer `:blank` concept has appeared in selector discussions and browser-related proposals, but it should not be substituted for the established `:empty` selector in a basic CSS question.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: