Skip to content

empty-heading

Reports a heading (<h1> to <h6>) with no text. White space is not text. An image with an alt or an <svg> inside counts as content.

Screen reader users move through a page by its headings, and an empty one is announced as a heading with nothing in it. It is usually a leftover or a heading whose text comes from a script that did not run.

To fix, put text in the heading, or remove it.

Reported
...
</head>
...
<h1></h1>
<h2><img src="a.png" alt="x"></h2>
<h3>text</h3>
...
angular:
lint:
rules:
empty-heading: warn # off (default), warn, error
html:
lint:
rules:
empty-heading: warn # off (default), warn, error
svelte:
lint:
rules:
empty-heading: warn # off (default), warn, error
vue:
lint:
rules:
empty-heading: warn # off (default), warn, error

Enabled by the presets: html/html-validate-recommended.

Suppress one line with sudsy-disable-next-line empty-heading in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
html-eslint no-empty-headings full
html-validate empty-heading full