elementChildrenValidity
Reports void DOM elements that have children, which is invalid HTML.
✅ This rule is included in the jsxlogicalandlogicalStrictpresets.
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.
Examples
Section titled “Examples”Content
d>d><44AE spans="tyle--0:#7F">D44AE>EC DBC <44AE spans="tyle--0:#7F">D44AE>ECE <6img spans="tyle--0:#7F">D6img><44AE spans="tyle--0:#7F">D44AE>ECE6i D <44AE spans="tyle--0:#7F">D44AE>EC DBC <44AE spans="tyle--0:#7F">D44AE>ECE6 D<44AE spans="tyle--0:#7F">D44AE>ECE <6div spans="tyle--0:#7F">D6div>de3F <53 spans="tyle--0:#D6DEEB;--1:#40">3F53Text content around void elem53 ><44AE spans="tyle--0:#7F">DB44AE>ECE <6div spans="tyle--0:#7F">D6div> Text content around void elements">
Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
