4 ms·
`<br />` was the correct way in XHTML to do HTML5's `<br>` (I think `<br />` still works in HTML5 or maybe browsers just don't mind it, but it's not the recomm
by joemi 7y ago
`<br />` was the correct way in XHTML to do HTML5's `<br>`
(I think `<br />` still works in HTML5 or maybe browsers just don't mind it, but it's not the recommended way.)
- buboard 7y agothanks i never got the news, i hope browsers dont hate me
- DarkStar851 7y agoHaha I've known for years and I still use <br />. Usually the linter will nag me, but otherwise I just don't care enough to fix it.
- buboard 7y agoi think the feeling of closure i get with the /> is addictive
- aitchnyu 7y agoHaving an unclosed tag somehow seems wrong. What was the reasoning behind this?
- c0vfefe 7y agoPerhaps they made it implicitly self-closing.
- taco_emoji 7y agoBecause HTML5 is not actually a subset of XML. Every element in XML must be closed, but in HTML5 certain tags (like <hr>, <img>, or <br>) are defined as "void" which means they have no nested content and therefore it's technically improper to close them (although I'd be shocked if any major browsers actually care about that). In other words, an <img> tag does not "open" the definition of a new section of the document the way <div> or <span> do, and it makes no sense to "close" something that was never "open" to begin with.
- papln 7y agoThat's an arbitrary style choice in the spec. Saying "it's void so never use / " is no more natural than saying "it's void so always use /". Arguably, it's bad style to use the same syntax for opening a tag as for a void tag, because it forces semantics into the syntax for trivial benefit. With out the "/", your HTML syntax parser now has to include a lexicon of all the void tags, and be updated with spec revisions.