The :empty pseudo-class matches elements that have no children — no nested elements and no text nodes (spaces count as text).
Use it for placeholder boxes, empty slots, or hiding blank containers. Comments alone do not break the match. Write truly empty tags like <div></div> with nothing between them.
Baseline · Widely available.
Not deprecated. CSS3 form. Safe across modern browsers.
Selectors Level 4 note.
The Level 4 spec would treat whitespace-only nodes as empty, but no browser ships that yet. Study and use the strict “no whitespace” behavior.
Caution. Do not hide interactive controls that need an accessible name.
Edge Cases & Pitfalls
If :empty seems broken, check these first.
space
Whitespace is content
<div> </div> or a newline between tags does not match. Use <div></div> with nothing in between.
nested
Nested empty child blocks the parent
<div><p></p></div> — the outer div is not empty because it has an element child.
comment
Comments are OK
An element that contains only an HTML comment still matches :empty.
a11y
Do not leave interactive controls empty
Buttons and links need an accessible name. Hide decorative empties, not unlabeled controls.
Level 4
Whitespace-as-empty is not shipping
Selectors Level 4 would change whitespace behavior. Until browsers catch up, assume spaces break the match.
Compatibility
Browser Support
The :empty pseudo-class is a browser CSS selector. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
:empty
Supported in all modern browsers (CSS3). Safe for teaching and production. Level 4 whitespace change is not implemented yet.
100%Core support
Google Chrome4+
Full support
Mozilla Firefox2+
Full support
Apple Safari3.1+
Full support
Microsoft Edge12+
Full support
Opera10+
Full support
Samsung Internet4+
Full support
Internet Explorer9+
Full support
:emptyUniversal
Bottom line: No prefixes. No polyfills. It is not a runtime API.
Remember
Key Takeaways
Role: match elements with no element or text children.
Whitespace: spaces and newlines prevent a match today.
Comments: comment-only content still matches :empty.
Tip: keep empty tags flush: <div></div>.
One line::empty styles elements that truly contain nothing — not even a space.
Frequently Asked Questions
It matches elements that have no children — no element nodes and no text nodes (including whitespace).
Yes, in every current browser. A space, tab, or line break between the tags creates a text node, so the element no longer matches :empty.
No. Comments and processing instructions do not prevent :empty from matching. CSS generated content also does not count.
The Level 4 spec would let whitespace-only nodes still match :empty (like :-moz-only-whitespace), but no browser implements that yet. Teach the strict CSS3 behavior.
Yes. It is Baseline Widely available (CSS3). It is a browser selector, not a Node.js or runtime API.
:blank is a newer idea that can treat whitespace-only as empty. Support is limited; prefer :empty for production teaching and code today.