Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 Doctype Support

Tags:

html

For a long time I have been using XHTML1.1 because I thought I was cool (yeah right). However, today I read Ian Hickson's Article about how everyone uses the wrong MIME type with XHTML and it opened my eyes a lot. I happen to be one of those people who are serving XHTML with text/html MIME, because like a lot of people, W3C says its "ok" to serve it this way.

At the top of that article he says that "now" he would serve it using the HTML5 doctype (!DOCTYPE HTML). What are your thoughts about doing this? If I did not use unsupported functionality, would it be ok? What would the MIME type be in this case?

Thanks for any help, Metropolis

like image 704
Metropolis Avatar asked May 29 '10 03:05

Metropolis


2 Answers

W3C doesn't say that it's OK to serve XHTML 1.1 as text/html. It says that it's OK to serve XHTML 1.0 as text/html.

The thing to understand with HTML5 is that it turns the relationship between syntax and mime type on its head. Instead of saying which mime types can be used with HTML and XHTML, HTML5 says that if you serve a page as text/html then it is HTML, and if you serve it as application/xhtml+xml then it is XHTML.

So the doctype doesn't matter in determining whether the page is HTML or XHTML. This is what browsers have been effectively doing for years, though it should be noted that most validators and some authoring tools do make use of the doctype to determine modes of operation. The new HTML5 validators such as validator.nu do use the mime type as the determining factor. What authoring tools should do is currently unclear, and is still being argued about within the HTML working group, but it seems likely that they will have to fall back on a mapping of file extensions, (e.g. filename.html versus filename.xhtml)

If only because HTML5 validators and all browsers do the same thing when confronted with the HTML5 doctype, its use has to be a good thing, even if you're not using any other HTML5 functionality. However, you should note that not all valid HTML4 is valid HTML5, and that many details of HTML5 are still being argued over. In some cases, recent and proposed changes may not be implemented in the HTML5 validator, so if you check your pages you may get things reported as errors that are valid HTML4, and may eventually be valid HTML5.

Finally, note that when serving your page as application/xhtml+xml, the HTML5 doctype is completely optional. Browsers simply ignore it.

like image 98
Alohci Avatar answered Sep 20 '22 02:09

Alohci


Google.com is already serving pages with the HTML5 doctype <!doctype html> (see source if you don't believe me), and if it's good for them it's good for me :)
Remember that valid HTML 4.01 strict are also valid HTML5 pages!

like image 33
Agos Avatar answered Sep 20 '22 02:09

Agos