megster.net

Nathan Russell

Nathan Russell

Do we need the html4 and xhtml doctypes anymore?

March 8, 2011, by admin, category html

html5 has its own doctype so I’m questioning whether we need the old ones anymore, and whether we should be actively looking to the future and driving things forwards.

The ‘old’ doctypes I’m talking about include:

  • HTML 4.01 Strict
    This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed.
    <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
  • HTML 4.01 Transitional
    This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like font). Framesets are not allowed.
    <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
  • HTML 4.01 Frameset
    This DTD is equal to HTML 4.01 Transitional, but allows the use of frameset content.
    <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Frameset//EN” “http://www.w3.org/TR/html4/frameset.dtd”>
  • XHTML 1.0 Strict
    This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed. The markup must also be written as well-formed XML.
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
  • XHTML 1.0 Transitional
    This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like font). Framesets are not allowed. The markup must also be written as well-formed XML.
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
  • XHTML 1.0 Frameset
    This DTD is equal to XHTML 1.0 Transitional, but allows the use of frameset content.
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd”>
  • XHTML 1.1
    This DTD is equal to XHTML 1.0 Strict, but allows you to add modules (for example to provide ruby support for East-Asian languages).
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>

OK, lets eliminate some of these. Who uses framesets these days? Exactly. So that’s those gone. Next, who uses presentational and deprecated elements? Well, if that’s you, you shouldn’t be! So we’ll take those off the list as well.

So that leaves us with html 4.01 Strict and two xhtml doctypes which for the purpose of this I am considering the same.

The html5 doctype is simply <!DOCTYPE html>

So what happens when we use the html5 doctype in a page rendered by an older browser which does not support html5? Wont it all go horribly wrong? Well, actually, a pretty neat thing happens – the browser is forced into standards mode. That can only be a good thing. Gone are the days where we try to implement designs with nasty browser specific hacks. We want to be developing to published, supportable standards (don’t we?), so using a doctype which forces the browser into a standards compliant rendering mode is good.

My personal view is that we should be looking forwards not backwards. html5 is the future so we should be embracing it. I acknowledge that the standards aren’t fully defined yet, and for the new html5 elements that are still recommendations we should perhaps take a more cautious approach. But I think that coding a site or application with a combination of the html5 doctype and html4 elements as well formed XML (xhtml) is a step in the right direction that we should all be taking now.

So, what do you think ?