Hacker News new | ask | show | jobs
by kedean 4060 days ago
He wasn't talking about closing void elements, he meant self-closing void tags, like <img/>, <br/>, and <hr/>. These were introduced by XHTML to fit with the idea that every tag needs to be closed. HTML5 does away with the requirement, but the HTML5 grammar does explicitly support self-closing tags (http://www.w3.org/TR/html5/syntax.html#self-closing-start-ta...). At this point, self-closing tags are more of a visual preference, as they have a negligable effect on parsing.
1 comments

At this point, self-closing tags are more of a visual preference, as they have a negligable effect on parsing.

In fact they can be said to have no effect on parsing HTML itself, as the only time when self-closing makes any difference is when the tag's name isn't one that HTML defines - what the spec calls "foreign elements" (e.g. inline SVG or MathML). Those will close when their tag is self-closing, but the closing behaviour of HTML tags is hardcoded in the parser.