Hacker News new | ask | show | jobs
by newjersey 3864 days ago
> "Be conservative in what you do, be liberal in what you accept from others"

Wikipedia has an example of a tag soup https://en.wikipedia.org/wiki/Tag_soup which is probably poster child example of this law:

<p>This is a malformed fragment of <em>HTML.</p></em>

What do we do here? Do we do what browsers have historically done? Or do we throw our hands up in the air when we see malformed tags?

1 comments

HTML5 includes a well-defined algorithm for parsing such constructs, so with the HTML5 doctype that fragment is actually well-formed and normalized to the tree you'd expect.
Wait, if HTML5 specifies how to handle it... doesn't that make it syntactically valid?
That's right as far as I can tell. For another example of markup that's entirely valid in HTML5 but still considered icky by some people, the spec section on tag omission has an example of how to write tables more easily by skipping all the end tags.