Skip to content

empty-tag-pair

Added in 1.0.0 · Related issues · View source

What it does

Checks for non-void elements with no attributes whose open and close tags wrap no content.

Why is this bad?

A bare <tag></tag> pair renders nothing, so it is often leftover scaffolding or a typo.

The HTML specification recommends, "as a general rule," that such elements contain at least one node of palpable content. That is explicitly not a hard requirement — an element may be empty legitimately "when it is used as a placeholder which will later be filled in by a script, or when the element is part of a template".

Example

<div>Welcome<span></span></div>

Use instead:

<div>Welcome</div>

References