3 ms·
>> But you cannot write <div id="mydiv" />. > Sure you can. And exactly as with <br/> the / is ignored. Obviously, the phrase "you cannot write" has the conte
by saurik 5y ago
>> But you cannot write <div id="mydiv" />.
> Sure you can. And exactly as with <br/> the / is ignored.
Obviously, the phrase "you cannot write" has the context "as a shorthand for self-closing the tag", and doesn't deserve some pedantic "of course you can do that, it just doesn't do what you hoped it would" response :/.
To really be pedantic about it: SGML actually had a feature similar to this feature and HTML specified it; however, the syntax "<br/" was a valid way to write that tag (technically an open tag, but due to the DTD it would auto close) and the ">" after would get rendered... not ignored (and in fact might even cause the document to fail if that > was in a disallowed context of a strict document).
https://jkorpela.fi/html/empty.html https://jkorpela.fi/html/empty.html
Ironically, the W3's comment on this is to discourage its usage "until widely deployed", as they have essentially always specified stuff no one implemented correctly (lol).
https://www.w3.org/MarkUp/html3/HTMLandSGML.html https://www.w3.org/MarkUp/html3/HTMLandSGML.html