Skip to content

elementChildrenValidity

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

✅ This rule is included in the jsx logical and logicalStrict presets.

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.

<
any
br
>text content</
any
br
>
<
any
img
>Invalid children</
any
img
>
<
any
input
>
<
any
span
>Not allowed</
any
span
>
</
any
input
>
<
any
hr
>{
const expression: React.ReactNode
expression
}</
any
hr
>;
<
any
meta
>
<
any
div
>Content</
any
div
>
</
any
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 ❤️‍🔥 around the world by the Flint team and contributors.