no-self-closing
Angular templatesHTMLVue / SvelteVue / Sveltecorrectnessno fixdefault: offhtml/html-validate-recommended
What it does
Section titled “What it does”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.
Why it matters
Section titled “Why it matters”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>).
Example
Section titled “Example”...<p style="display: none">ok</p>...<br><div /><svg viewBox="0 0 1 1"><linearGradient gradientUnits="x"></linearGradient></svg></body></html>Configuration
Section titled “Configuration”angular: lint: rules: no-self-closing: warn # off (default), warn, errorhtml: lint: rules: no-self-closing: warn # off (default), warn, errorsvelte: lint: rules: no-self-closing: warn # off (default), warn, errorvue: lint: rules: no-self-closing: warn # off (default), warn, errorEnabled 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.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| html-validate | no-self-closing |
full |