Skip to content

empty-tag-pair

Preview (since 0.2.10) · Related issues · View source

This rule is unstable and in preview. The --preview flag is required for use.

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