2 ms·
I don't think you're correct about that. Here's simple test.xhtml: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head>
by vbezhenar 6y ago
I don't think you're correct about that.
Here's simple test.xhtml:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta charset="UTF-8"/>
<title>XHTML</title>
</head>
<body>
<p>
<details>
<summary>Summary</summary>
Details
</details>
</p>
</body>
</html>
It's rendered properly in Chrome. If some XML is wrong, it'll error. So at least Chrome supports XHTML with strict XML validator. And <detail> tag works as expected and it's even nested inside <p> tag in DOM.
That XHTML won't pass validator.w3.org (<details> can't be inside <p>), but Chrome does not care.
- chrismorgan 6y agoHuh, I thought the XML serialisation of HTML had been evicted from all the browsers, but you’re right, and Firefox behaves the same way. https://html.spec.whatwg.org/#html-vs-xhtml https://html.spec.whatwg.org/#html-vs-xhtml describes briefly what is expected to occur (though that section is non-normative). Also given that I know that browsers can successfully load XML documents with XSLT (I’ve seen one or two web pages that actually do this), and that I know that the XML parser is accessible via DOMParser (this can be useful for some kinds of markup sanitisation), I’m not sure why I thought XHTML was completely dead in this way. Something’s niggling at the back of my mind, but I can’t place it. I believe browsers would be quite within their rights to do DTD validation and consequently reject such a document as this, but they don’t actually do so. (Even if the DTD is specified correctly for XHTML 1.0 Strict, nothing changes.) Thanks for correcting me. I have updated my mental knowledge repository.
- ttepasse 6y ago> I’m not sure why I thought XHTML was completely dead in this way. Something’s niggling at the back of my mind, but I can’t place it. Browsers were always non-validating XML processors. Maybe you're thinking about the Well-formedness constraints? These constraints check if an XML document follows the XML metasyntax and any XML processor is required to fail [1] on errors in these contraints. And browsers do that. [1] https://www.w3.org/TR/2006/REC-xml11-20060816/#sec-conformance https://www.w3.org/TR/2006/REC-xml11-20060816/#sec-conforman... In practice most well-formedness violations were nesting errors like missing start or end tags, common when generating XML via text concatenation or templates, which in the dark times a lot of people do, even when they shouldn't . [2] That's why the HTML5 parsing algorithm is so complex and almost unimplementable. It's the ambition for error correction: It tries to generate a DOM out of any well-formed and unwell-formed documents. [2] https://hsivonen.fi/producing-xml/#nottext https://hsivonen.fi/producing-xml/#nottext