HTML DocType Text: World’s Tiniest and Shortest HTML DocType Declaration

by Yang Yang on January 9, 2009

Dustin Diaz made an interesting discovery to trigger “standards mode” with just a tiny little declaration instead of the regular lengthy one we see everywhere.

As opposed to “standard mode”, there’s this “quirks mode” in IE that accommodates legacy HTML code of no standards at all – rendering them in many different ways compared with standardized HTML who has a harassing top declaration of document type. For example, common HTML document declarations include:

HTML 4.01 Transitional

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">

XHTML 1.0 Strict

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

XHTML 1.0 Transitional

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

XHTML 1.0 Frameset

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

For a more detailed collection of HTML doctypes, read here.

However, except for the sake of validation, a declaration usually counts for nothing. The only purpose of leaving one at the top of every web page you create is for the client browser to make the HTML out in standard way rather than in quirks way. Dustin has found a rather convenient short cut for this:

<!doctype html>

It’s much more memorable and correctly triggers the standard mode. We call it the skinny html doctype.

Jose January 9, 2009 at 6:04 pm

cool, since im only starting to learn html, this is way easier.

Yang Yang February 26, 2010 at 4:09 pm

It actually has become the standard of HTML 5.

Comments on this entry are closed.

Previous post:

Next post: