Declare Your Doctype
I was thinking random, so I Googled ‘bicycling‘. Clicked ‘view source’ and what did I see?
Eight of the top ten sites don’t declare a DOCTYPE.
In case your not sure where I’m looking, the DOCTYPE should be the very first thing in your HTML / XHTML page. Right smack up top.
Are you declaring any DOCTYPE’s today sir?
A DOCTYPE aka DTD aka Document Type Definition, tells the web browser how to interpret and display your HTML. Today’s generation of web browser’s use it more than the last. And, that is the vital point.
As the generation of browser’s advance; as internet usuage expands to cell phones, pda’s and whatever else is coming; it will be more important then ever to correctly identify your HTML / XHTML (XML, WML, MML) with the proper DOCTYPE.
Your sloppiness is my gain
I firmly believe that a day of reckoning will come for this 80% of the web that zing through the ether without a DOCTYPE. Yes. Mozilla, Mircosoft, Opera, et al will not doubt carry these wounded web sites via Quirks Mode for quite a while. But, someday in the not so distant future, we web designers will have a slew of business fixing what is broken.
Where can I get one of those DOCTYPES?
They’re free for the taking. Each flavor has different markup stipulations.
Here they are in all their glory:
HTML 4.01
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN”
“http://www.w3.org/TR/html4/strict.dtd”>
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
“http://www.w3.org/TR/html4/loose.dtd”>
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Frameset//EN”
“http://www.w3.org/TR/html4/frameset.dtd”>
XHTML 1.0
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd”>
XHTML 1.1
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN”
“http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
A full blown XHTML template
This one uses XHTML 1.0 Strict. You can change it to a different (more transitional) type if you want. Although Strict is a fun challenge!
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<title>An XHTML 1.0 Strict standard template</title>
<meta http-equiv=”content-type”
content=”text/html;charset=utf-8″ />
<meta http-equiv=”Content-Style-Type” content=”text/css” />
</head>
<body>
<p>… Your HTML content here …</p>
</body>
</html>