3 ms·
We're not talking about div, we're talking about link. Self-closing tags with the trailing slash are absolutely supported by HTML5, in some circumstances.
by kiitos 2y ago
We're not talking about div, we're talking about link.
Self-closing tags with the trailing slash are absolutely supported by HTML5, in some circumstances.
- codedokode 2y agoNo, spec authors simply added a rule to ignore the slash because Internet was full of garbage code and they realized that it is hopeless to expect low-quality frontend developers to fix their code. There is no such thing as "self-closing element" in HTML spec (only SVG and MathML have them because they are based on XML). Quoting the spec [1]: > Then, if the element is one of the void elements, or if the element is a foreign element, then there may be a single U+002F SOLIDUS character (/), which on foreign elements marks the start tag as self-closing. On void elements, it does not mark the start tag as self-closing but instead is unnecessary and has no effect of any kind. For such void elements, it should be used only with caution — especially since, if directly preceded by an unquoted attribute value, it becomes part of the attribute value rather than being discarded by the parser. [1] https://html.spec.whatwg.org/#start-tags https://html.spec.whatwg.org/#start-tags
- andrewfromx 2y agowow codedokode for the win!
- kiitos 2y agoYes, but that clearly indicates it's a supported syntax, which contradicts what you said up-thread. That's the only point I was making.