It’s Safe to Use the HTML5 Doctype Today

If you’ve taken a look at Google’s source code lately (and really, who hasn’t?) you may have noticed that they’re already using the HTML5 doctype instead of either HTML4 or XHTML.

<!doctype html>

It’s certainly much easier to type that then hunt down and paste in the monstrosity required for HTML4 or XHTML.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

From what I’ve managed to divine from the inter-tubes, the doctype is fully backwards-compatible with aging browsers like Internet Explorer 6. It will ensure that your document is not rendered in quirks mode. Modern browsers, and validators, should recognize it specifically as the new doctype used for HTML5 documents as well.

As a matter of fact, it’s quite all right to start coding your documents as HTML5, so long as you stay away from shiny new features that haven’t been implemented satisfactorily across browsers yet. You probably don’t want to be using the canvas or video elements, for example, for anything on sites that have visitors using older browsers. (Not to mention that there’s a silly standards war going on involving video codecs…) But for the most part, HTML5 works like HTML4.

HTML5 defines an HTML syntax that is compatible with HTML4 and XHTML1 documents published on the Web, but is not compatible with the more esoteric SGML features of HTML4, such as processing instructions and shorthand markup as these are not supported by most user agents.

Some elements’ definitions have been changed slightly, but for the most part things are as they have been. It’s probably worth reading up on the differences between HTML5 and HTML4.

John Resig said it pretty well:

What’s nice about this new DOCTYPE, especially, is that all current browsers (IE, FF, Opera, Safari) will look at it and switch the content into standards mode – even though they don’t implement HTML5. This means that you could start writing your web pages using HTML5 today and have them last for a very, very, long time.

  • Derby web design studio

    We moved to the HTML 5 doctype last year and have no issues since. It’s clean and simple the way it should be.