Skip to content

elementChildrenValidity

Reports void DOM elements that have children, which is invalid HTML.

✅ This rule is included in the jsx logical preset.

Void elements (also called self-closing or empty elements) are HTML elements that cannot have children. These elements, such as <br>, <img>, and <input>, are self-closing by definition and attempting to give them children violates the HTML specification.

<br>text content</br>
<img>Invalid children</img>
<input>
<span>Not allowed</span>
</input>
<hr>{expression}</hr>
<meta>
<div>Content</div>
</meta>

This rule is not configurable.

If your application is a rare one that violates HTML standards and places invalid children inside standard elements, this rule may be counterproductive for you.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.