Any reason not to start using the HTML 5 doctype?

71,838

Solution 1

Well consider this:

When serving as text/html, all you need a doctype for is to trigger standards mode. Beyond that, the doctype does nothing as far as browsers are concerned.

When serving as text/html, whether you use XHTML markup or HTML markup, it's treated by browsers as HTML.

So, really it comes down to using the shortest doctype that triggers standards mode (<!DOCTYPE html>) and using HTML markup that produces the correct result in browsers.

The rest is about conforming, validation and markup prerference.

With that said, using <!DOCTYPE html> now and trying to make your markup conform to HTML5 is not a bad idea as long as you stick to stable features that work in browsers now. You wouldn't use anything in HTML4 or XHTML 1.x that doesn't work in browsers, would you?

In other words, you use <!DOCTYPE html> with HTML4-like markup while honoring things that have been clarified in HTML5. HTML5 is about browser compatibility after all.

The downside to using HTML5 now is that the spec can change quite often. This makes it important for you to keep up with the spec as it actively changes. Also http://validator.nu/ might not always be up-to-date, but http://validator.w3.org/ isn't always up-to-date either, so don't let that stop you.

Of course, if you want to use XHTML 1.0 markup and conform to XHTML 1.0, then you shouldn't use <!DOCTYPE html>.

Personally, I always use <!DOCTYPE html> for HTML.

Solution 2

My question to you would be why use it if you don't use any of the new/unsupported features. I'm not saying you couldn't play around with it, but why start building sites with a doctype that offers no benefits and could be supplemented by XHTML5.

Solution 3

I'd say use it and test extensively. Then let us know if it blew your house up or something. :')

Solution 4

Based on the latest IE8 beta, it seems that MS will use the HTML5 doctype as a bypass for the IE8 mode switching quagmire. It seems that the biggest risk with deploying the HTML5 doctype early is that if people publish a lot of IE8-incompatible content with the HTML5 doctype before IE8 ships, MS might get cold feet about making the mode situation simple for HTML5.

Update: This has been voted down, it seems. Quite obviously now that IE8 has shipped, the above consideration no longer applies. And indeed, the situation is not simple with IE8.

Solution 5

The downside for me mainly concerns validation:

  1. Third party validation tools does not always keep up with changing specs, making my favorite tools unreliable.
  2. I prefer to validate against strict doctypes to make sure I have closed all elements. It's an easy way to avoid simple but time consuming nesting errors. With HTML 5 you don't have to close your elements, so there is no way to find unmatched tags.
Share:
71,838
Ricky
Author by

Ricky

Engineer at Mozilla

Updated on August 20, 2020

Comments

  • Ricky
    Ricky over 3 years

    It is supposed to be backwards compatible with HTML4 and XHTML. John Resig posted about some of the benefits.

    As long as we don't use any of the new and not supported yet features, would there be any downside to start building sites with this doctype?

  • topepo
    topepo over 15 years
    It's about semantics. You could perfectly well get rid of almost every single tag in HTML and use nothing but div, span and style/class attributes. But you remove all semantic value from the document by doing so.
  • andrewmu
    andrewmu over 14 years
    I thought that omitting the URI throws browsers into quirks mode, thus making working to standards a futile effort.
  • Leo Jweda
    Leo Jweda over 14 years
    Just think of how useful it'll be for search engines.
  • andrewmu
    andrewmu over 14 years
    @Laurent: So if I want a header to be now a sidebar, I have to go through all my css and markup switching them around because it's no longer semantically correct? No. Make it a div, call it what it does and use it how you will. @Laith:In what respect will it be good for search engines?
  • andrewmu
    andrewmu over 14 years
    Canvas: Want to use it? You can't. Or you can, but you are now in the land of targeted programming. Which is not the point of standards.
  • Skilldrick
    Skilldrick over 14 years
    Why can't you use XHTML 1.0 markup as <!DOCTYPE html>? I thought that was the point!
  • Shadow2531
    Shadow2531 over 14 years
    Skilldrick, you can write polyglot docs yes. stackoverflow.com/questions/1079427/what-is-a-polyglot-docum‌​ent
  • Joe Dargie
    Joe Dargie about 14 years
    “I thought that omitting the URI throws browsers into quirks mode” — Nope. A big part of the work on HTML5 was Ian Hickson relentlessly testing lots of commonly-used browsers to see what worked, and how. The HTML5 doctype triggers standards mode in (I believe) all browsers that have such a thing.
  • Joe Dargie
    Joe Dargie about 14 years
    “Why use it if you don't use any of the new/unsupported features” - because it’s shorter and easier to remember? Not a big thing, obviously, but still.
  • Joe Dargie
    Joe Dargie about 14 years
    “Make it a div, call it what it does and use it how you will.” — Damn straight. Whilst you’re at it, do the same for all your paragraphs and lists. How do I type a sarcmark here.
  • Talvi Watia
    Talvi Watia about 14 years
    Yeah, but wouldn't that be XHTML 1.2 or XHTML 2.0? ;)
  • Marco Demaio
    Marco Demaio almost 14 years
    @grahm.reeds: according to wikipeda table en.wikipedia.org/wiki/Quirks_mode#cite_note-sivonen-1 HTML 5 triggers full STANDARD MODE.
  • Syntax Error
    Syntax Error almost 14 years
    If it helps, I just tested <!DOCTYPE html> in IE8, IE7 (using IE8 dev tools), and IE6 (using Virtual PC). None of them went into quirks mode. So even old IE can definitely handle the standard HTML5 doctype without going into quirks mode.
  • JqueryToAddNumbers
    JqueryToAddNumbers about 13 years
    yeah i'll just make a canvas game with an image tag! HTML5 ROCKS, no doubt about it. anyway, no-one uses i.e
  • Kzqai
    Kzqai almost 13 years
    That is true, which is why you want to look for a html lint checker: lint.brihten.com/html/help instead of simply the validator.
  • Chris Harrison
    Chris Harrison almost 13 years
    HTML5 is 'XHTML5'. The W3C has discontinued development of 'X'HTML.
  • Delan Azabani
    Delan Azabani over 12 years
    Well not really. XHTML5 and HTML5 are two different markup representations (serialisations) of the HTML language. The former is XML-based, and the latter is a unique dialect (with special parsing semantics) of SGML.