Skip to content

no-self-closing

Reports an element that is self-closed with /> and is not a void element (<div />). Void elements (see void-style), <svg> and <math> are not reported.

In HTML <div /> is a start tag: the browser ignores the slash and the element stays open and swallows what follows, so the page differs from what the markup seems to say.

To fix, write the end tag (<div></div>).

Reported
...
<p style="display: none">ok</p>
...
<br>
<div />
<svg viewBox="0 0 1 1"><linearGradient gradientUnits="x"></linearGradient></svg>
</body>
</html>
angular:
lint:
rules:
no-self-closing: warn # off (default), warn, error
html:
lint:
rules:
no-self-closing: warn # off (default), warn, error
svelte:
lint:
rules:
no-self-closing: warn # off (default), warn, error
vue:
lint:
rules:
no-self-closing: warn # off (default), warn, error

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

Suppress one line with sudsy-disable-next-line no-self-closing 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-validate no-self-closing full