Is there any reason why someone would need an XML prolog in an HTML5 document? I’m not talking about XHTML5. I’m just talking about a regular run-of-the-mill HTML page that uses the HTML5 docytpe.
Would there be any reason to have to include an XML prolog at the top of such a document?
The XML prolog (specifically the XML declaration) indicates that a document is XML. If the page is not well-formed XML, then you should definitely not include it.
However, data is good… The browsers I tested this on (Firefox and Chrome in Ubuntu) had no visible problems with an XML declaration at the top of an HTML 5 page, even though the page was not well-formed XML. The reason, of course, is that the HTTP server continued to serve the pages with the
text/htmlcontent type.Even though my small test didn’t reveal errors, I can’t think of any reason why this would be a good practice. If the page is HTML5, then it may not be XML, and should not be indicated as such. Browsers may not have a problem with this, but other tools, which look at the declaration instead of the content type, might make other assumptions.