Strict Document Type

Over the last couple of weeks I've been asked how to deal with various problems caused by one browser acting differently from another. My response is always to use the strict doctype. This usually gets results.

Most people use the transitional doctype. Not because they're still in the habit of using deprecated commands or because they have code that's written incorrectly, but because that's what they used when they first started coding in XHTML, and haven't changed since.

The problem is that transitional code makes browsers paranoid. They're worried that your code is hiding some kind of bomb under it's transitional coat. So they twitch a little and their hands shake and all of their little idiosyncracies are exposed to the light of day.

Man in a Coat

This man may have a bomb in his coat.

Strict doctypes change all that. You've promised that you've already checked his coat for bombs, that there were no bombs under his coat and that the browser can still the thunderous beating of its heart.

So, the next time you start a webpage, use this doctype instead:

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

Note: This really helps in making all the Internet Explorers, even IE6, look much closer to everyone else. If you're having trouble with IE, this is a really useful change you can make.