:empty - CSS Selector
Summary of characteristics of the :empty selector
Description of the :empty pseudo-class.
The pseudo-class selector :empty targets empty elements, meaning those that have no content and no child elements.
Comments are considered empty, but be careful with spaces that may appear before or after the comment.
Examples of empty paragraphs:
p/p
p!-- Comment --/p
Example of a non-empty paragraph:
p
!-- Comment --
/p
If content is added by the content property before or after the element, this content is not taken into account to determine if the element is empty.
Unfortunately, the pseudo-class :empty doesn't apply to input fields in a form.
Level 4 of the specification states that elements that contain only one or more spaces should be considered empty, and therefore targeted by the pseudo-class
:empty. This is more in line with what the user sees.
Example of use of the pseudo-class :empty.
The example below shows the effect of the pseudo-class :empty on table cells: empty cells have a red outline, in addition to the black border
common to all cells.
The last cell contains a space. The latest version of the standard specifies that spaces should be considered empty content, but no browsers handle this
peculiarity at the moment (2026).
| Monday | Tuesday | Wednesday | Thursday | Friday |
| Swimming | Footing | Squash |
The operation is exactly the same on a grid (below). The second cell is indeed empty, while the last cell contains a span element: so it’s not considered empty, even though the span element itself is empty.
We can also see that the content generated by the content property (the dashes) isn't taken into account when determining empty cells.
Browser compatibility with :empty.
The pseudo-class :empty is well recognized by current browsers. On the other hand, treating elements that contain only one or more spaces
as empty is far from being supported (2026).
:empty pseudo-class, which targets empty elements (elements that have no content).:emptypseudo-class
spaces
Browsers on computers :
Mobile browsers :
Outdated or marginal browsers :

Internet Explorer

UC Browser pour Androïd

Opéra Mobile

QQ Browser

Baidu Browser

Samsung Internet

Edge

Firefox

Chrome

Safari sur IOS

Androïd Brower

KaiOS Browser

Opéra

Safari

Chrome pour Androïd

Firefox pour Androïd

Opéra mini
Historic of the :empty pseudo-class.
-
Selectors Level 3
This document describes the selectors that already exist in CSS1 and CSS2, and further introduces new selectors for CSS3 and other languages that may need them.
Regarding:emptyIntroduction of the pseudo-class:empty.August 03, 1999Working Draft.November 13, 2001Candidate Recommendation.December 15, 2009Proposed for recommendation.September 29, 2011Recommendation . -
Selectors Level 4
This specification module defines new selectors that can be used in CSS.
Regarding:emptyLevel 4 of the specification now provides that the pseudo-class:emptytargets elements that contain only spaces.September 29, 2011Working Draft.
See also: DOM-related pseudo-classes.
Many pseudo-classes allow you to target elements based on their position in the document tree (DOM).








@scope directive.



