3 ms·
I found some references here: "Custom elements cannot be self-closing because HTML only allows a few elements to be self-closing" https://developers.google.co
by marianoguerra 5y ago
I found some references here:
"Custom elements cannot be self-closing because HTML only allows a few elements to be self-closing"
https://developers.google.com/web/fundamentals/web-components/customelements https://developers.google.com/web/fundamentals/web-component...
It seems only void elements are allowed to be self closing:
https://html.spec.whatwg.org/multipage/syntax.html#void-elements https://html.spec.whatwg.org/multipage/syntax.html#void-elem...
The trailing U+002F (/) in a start tag name can be used only in foreign content to specify self-closing tags. (Self-closing tags don't exist in HTML.) It is also allowed for void elements, but doesn't have any effect in this case.
https://html.spec.whatwg.org/multipage/parsing.html#parse-error-non-void-html-element-start-tag-with-trailing-solidus https://html.spec.whatwg.org/multipage/parsing.html#parse-er...
- claviska 5y agoValid custom elements must also contain a dash.
- tannhaeuser 5y agoThe important bit here being that the custom element API simply doesn't allow declaring all relevant features of elements except their names. Whereas (SGML) DTDs such as in any DTD for HTML before HTML5, elements were declared like this <!element img - - EMPTY> for elements with declared content EMPTY ("void elements" in HTML5 parlance), and <!element html O O (head,body)> as a basic example for tag omission/inference, where given these tag omission indicators (the letter O in the respective position), you can omit the html tags (and also head, and many other start- and end-element tags) when SGML can unambiguously infer those for you.