Disallow self-closing elements
- Rule ID:
- no-self-closing
- Category:
- Style
- Standards:
- HTML5
Require regular end tags for elements even if the element has no content, e.g. require <div></div>
instead of <div/>
.
This rule has no effect on void elements, see the related rule void-style
.
Rule details
Examples of incorrect code for this rule:
<div/>
Examples of correct code for this rule:
<div></div>
<!-- foreign elements are ignored -->
<svg/>
<!-- elements with XML namespace are ignored -->
<xi:include/>
Options
This rule takes an optional object:
{
"ignoreForeign": true,
"ignoreXML": true
}
ignoreForeign
By default foreign elements are ignored by this rule.
By setting ignoreForeign
to false
foreign elements must not be self-closed either.
<svg/>
ignoreXML
By default elements in XML namespaces are ignored by this rule.
By setting ignoreXML
to false
elements in XML namespaces must not be self-closed either.
<xi:include/>