traq;11033021 wrote:At the end of the day, a valid doctype triggers "Standards Mode" in browsers
Which today means HTML 5, since HTML 5 supersedes previous html versions. Wether you provide a valid html doctype for 4.01 (including the dtd), or simply <!DOCTYPE html> makes no difference - it will still be considered an HTML 5 document - Assuming the browser supports HTML 5. Since HTML 5 is based on parsing rules instead of SGML dtds, it will always be processed in the same way and the dtd will be ignored.
As far as the doctype declaration goes, there would be two exceptions to the above. The first is if the browser doesn't recognize <!DOCTYPE html> as a valid doctype declaration. Which in turn means the browser do not recognize HTML 5 even partially. And the second would be to provide an incorrect doctype declaration so that the document cannot be considered html.
The choice then boils down to serving your html 5 document as an html or an xml serialization.
If you serve it as xml, you do not need the doctype declaration at all since it will be ignored. But you may leave it there. The only thing used to decide that this is an xhtml 5 document is the mime type: application/xhtml+xml. You will need an xml declaration, which must be the very first thing in the document (BOM ok?): <?xml ...>. You will also need to provide a default namespace on your root element: <html xmlns="go look it up somewhere">. Thus it would look something like
<?xml ...>
<!DOCTYPE html>
<html xmlns="go look it up">
and be served as application/xhtml+xml. The doctype declaration may be left out, but if it is present, DOCTYPE must be in upper case letters.
While the html serialization would be
<!DOCTYPE html>
<html>
served as text/html. And the doctype is still there only for legacy reasons so that some browser doesn't jump into IE5 mode, which it may do if your doctype declaration is incorrect. But you would not intentionally do that, would you?
As for some of the differences that I find may be of importance:
- No use of document.write in xml documents
- No use of noscript elements in xml documents
- cAsInG matters in xml documents.
- no namespaces in html