News for hackers. Stuff that matters.
Re:Using Standard HTML (1997) by JoshTriplett on Sunday January 19, 2020 @02:28PM (#22093390)
Unfortunately, the XML-style syntax with all tags closed isn't allowed in HTML for certain tags. For instance, you can't close <input> or <br> or <hr> tags.
Re:Using Standard HTML (1997) by firefoxd on Sunday January 19, 2020 @02:34PM (#22093431)
Yes you can.

    <input />, <br />, and <hr />
And it is valid XML. They are referred to as self closing tags.
Re:Using Standard HTML (1997) by rimliu on Sunday January 19, 2020 @03:39PM (#22093890)
It is valid XML. It means totally different thing in HTML.
Re:Using Standard HTML (1997) by detaro on Sunday January 19, 2020 @03:44PM (#22093923)
The self-closing form is fine in HTML5 for those examples, since they are void elements. The "/" gets ignored, which is what you want in that case.

It fails if you try this with non-void elements: E.g. XHTML <div /> might turn into <div> in HTML5, which opens a div element, which is not the same. (I'm not sure if this behaviour is specified or not)

https://html.spec.whatwg.org/multipage/syntax.html#start-tag...

> 6. Then, if the element is one of the void elements [...] then there may be a single U+002F SOLIDUS character (/). This character has no effect on void elements [...]

https://html.spec.whatwg.org/multipage/syntax.html#void-elem...

> area, base, br, col, embed, hr, img, input, link, meta, param, source, track, wbr