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.

This rule should not be disabled as void elements with children violates the HTML specification and will cause unpredictable browser behavior.

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