← TechnologyThe essentials of

:empty and the empty space between tags

Publisher: ResumeMaker • 1 source

Published: 22 Oct 2026 13:13 · Updated: 22 Oct 2026 13:13

AI source check: 21 Oct 2026 13:48. This is not editorial approval.

In a few sentences

In brief

An item with no visible text is not always empty for the selector.

Useful to know

:empty selects an item without children. In usual browser implementations, text nodes, including empty spaces and new lines, affect the match. Comments do not. [1]

<div></div> matches, while <div> </div> may not match because of the interval. This is important in a template that leaves indentations in an empty container. MDN also describes the difference between the newer definition in specification and implementations. For a critical condition such as "no results" it is more reliable for the application to note it explicitly, rather than relying only on a visual void.

Sources

For further detail and to check the information:

  1. [1] MDN — :empty ↗