HTML5 DocType

Wed, 17 Nov 2010

Most of us are used to copy/pasting those long ugly DocType's in our XHTML/HTML pages. It appears XHTML will be short lived with the promising HTML 5 release. With the HTML5 DocType it's extremely simple to implement, and HTML 5 does not rely on a DTD. See the examples below:

HTML DocType
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
HTML5 Doctype
<!DOCTYPE HTML>

What if you have an HTML 4 document and you use the HTML5 DocType? Just use the new DocType from now on, it will implement the appropriate DTD if the client has an earlier browser that doesn't support HTML5!