开发者

How do I force a browser to render a file XHTML5, the XML serialization of HTML5?

开发者 https://www.devze.com 2023-02-27 10:27 出处:网络
Is there anyway to force a browser to render XHTML5, the XML serialization of HTML5? Obviously, you can do it with server-side control of the mime-type, but is there a supported way to invoke the XML

Is there anyway to force a browser to render XHTML5, the XML serialization of HTML5? Obviously, you can do it with server-side control of the mime-type, but is there a supported way to invoke the XML seriali开发者_如何学JAVAzation using a file?

A test of this would be rendering   recent versions of Chromium will actually halt rendering if they encounter this element. How do I invoke this same behavior by opening an invalid XHTML5 document.


is there a supported way to invoke the XML serialization using a file?

If you mean "when loading from the local filesystem" then just give the file a .xhtml file extension.

A test of this would be rendering   recent versions of Chromium will actually halt rendering if they encounter this element.

That isn't a very good test. It just means that the parser is a generic XML parser rather than one that is XHTML 5 aware. The specification says using them is 'unsafe' not 'forbidden'.

According to the XML specification, XML processors are not guaranteed to process the external DTD subset referenced in the DOCTYPE. This means, for example, that using entity references for characters in XHTML documents is unsafe if they are defined in an external file (except for <, >, &, " and ').

If you want to do a proper test, then make the document non-well-formed. e.g. by leaving off the end tag for a paragraph (which is allowed in HTML but not in XHTML).


&nbsp; is a valid named character reference in (X)HTML5

Update: Oops, that sections only applies to the HTML serialisation, so it's not relevant.

0

精彩评论

暂无评论...
验证码 换一张
取 消