4 ms·
> HTML parsing is not stable and a line of HTML being parsed and serialized and parsed again may turn into something rather different This is why people should
by nayuki 10mo ago
> HTML parsing is not stable and a line of HTML being parsed and serialized and parsed again may turn into something rather different
This is why people should really use XHTML, the strict XML dialect of HTML, in order to avoid these nasty parsing surprises. It has the predictable behavior that you want.
In XHTML, the code does exactly what it says it does. If you write <table><a></a></table> like the example on the mXSS page, then you get a table element and an anchor child. As another example, if you write <table><td>xyz</td></table>, that's exactly what you get, and there are no implicit <tbody> or <tr> inserted inside.
It's just wild as I continue to watch the world double down for decades on HTML and all its wild behavior in parsing. Furthermore, HTML's syntax is a unique snowflake, whereas XML is a standardized language that just so happens to be used in SVG, MathML, Atom, and other standards - no need to relearn syntax every single time.
- bayesnet 10mo agoI don’t think this is right. XHTML guarantees well-formedness (matched closing tags et al) but doesn’t do anything for validity. It’s not semantically valid for <td> to be a direct child of <table>, so the user agent has to make the call as to what to display regardless of the (X)HTML flavor. The alternative is parsing failure on improperly nested HTML which I don’t think is desirable.
- intrasight 10mo ago> The alternative is parsing failure on improperly nested HTML which I don’t think is desirable. It was that decision that resulted in the current mess. Browser vendors could have given us a grace period to fix HTML that didn't validate against the schema. Instead they said "there is no schema"
- bayesnet 10mo agoThe issue as I see it is that XML schemas are fine[0] for immutable documents but not suited for dynamic content. As a user it would be extraordinarily frustrating for a site or web app to break midflow because of a schema validation failure after a setHTML call or something. [0]: I’ve worked with XML schemas a lot and have grown to really dislike them actually but that’s neither here nor there
- intrasight 10mo agoUsers would be angry at any buggy software. Yours is just another example of buggy software. Strongly typed software is a pain but it's benefits are starting to be recognized again. Unfortunately it's too late for XML.
- favorited 10mo agoYou might as well complain about Betamax. XHTML is not the future.
- recursive 10mo agoHTML is also a standardized language.