Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make XHTML5 validate correctly and ENTITY parseable as XML

I'm switching from XHTML 1.0 Strict to XHTML5, but I'm having issues with the default DOCTYPE declarations -- the documents no longer validate as XML, and cannot be loaded in some browsers when served as application/xhtml+xml with the .xhtml extension, mostly because of the entities like — etc.

I've tried just putting back the XHTML 1.0 Strict DOCTYPE and stuff, and it all works in the browsers as expected (no XML parsing errors, and the new article elements still work all right), but it no longer validates by W3 as valid HTML5, due to the meta charset specification from HTML5, for example.

How do I automatically import the entities to make the browser validate XML, but specify HTML5 for the W3 validator?

like image 725
cnst Avatar asked Nov 08 '22 16:11

cnst


1 Answers

Use numeric HTML entities such as & for ampersands for both the HTML and XML parsers instead of & which are not valid entities. Usually MDN (Mozilla Developer Network) has reliable information and I loath W3Schools so December has a fairly exhaustive list and I'd also highly recommend the Unicode Character Table website.

My platform and website (link in my profile) is served as XHTML5 and utilizes UTF8 characters in place of images (fewer HTTP requests for better performance).

As far as doctypes are concerned you didn't specifically mention which versions of which browsers so you'd need to comment in order for me to look in to it. I have installers going all thew way back to Opera 2 and Mozilla Suite 0.8. :-)

like image 180
John Avatar answered Nov 15 '22 05:11

John