<self-closing />
tag are not allowed in HTML custom element.
Why is that?
Many cases just need void tag, I guess by that, code would be more readable. On the other hand, it implies semantic meaning more directly.
Just like <hr />
, which by code itself means there shouldn't be any children inside it, because there's no place for that.
Plus it has nothing to do with children.
Custom elements cannot be self-closing because HTML only allows a few elements to be self-closing. (read more)
The browser has to special case void elements so it knows to close them immediately without looking for an end tag.
No custom element will be in a browser's internal list of void elements.
Remember, the significant thing that indicates an element is void is the tag name. The optional /
is just syntactic sugar for people and syntax highlighters that are still trying to think in terms of XML. It's meaningless to an HTML parser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With