What is a DOCTYPE anyway ?
The DOCTYPE is not as shady or confusing as it seems, it very simple stuff. DOCTYPE stands for Document Type and its main purpose is to inform, in our case, browsers, about the kind of documents we are producing. Mmm lets try again, by specifying a DOCTYPE we tell the browser how to handle our pages. Thats it, simple stuff.
Once a upon a time the W3C started to organize all the mess everybody called the internet, one of the many things they recomended was that every document should have a DOCTYPE, the bad thing, nobody listened. We all remember that era; thankfully, today a lot of people are moving towards standards, giving the DOCTYPE the importance it deserves.
The Basics
The DOCTYPE declaration should precede any markup in your page. Actually, in XHTML documents, this declaration follows the XML prolog, which is the first tag inside our pages. But wait, before you type in the XML prolog consider that older version of Netscape Navigator and, believe it or not, recent versions of Internet Explorer choke on the prolog. We strongly recomend skipping the prolog, don’t feel bad, the W3C has made its declaration optional.
Ok, show me how. It easy, just put any of the following DOCTYPE declarations at the top of your document.
For HTML 4.01 you can use the following declarations:
For strict HTML documents
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
“http://www.w3.org/TR/html4/strict.dtd”>
For HTML transitional
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
“http://www.w3.org/TR/html4/loose.dtd”>
For HTML frameset
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Frameset//EN”
“http://www.w3.org/TR/html4/frameset.dtd”>
For XHTML 1.0 you can use any the following declarations
For XHTML 1.0 strict documents
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
For XHTML 1.0 transitional documents
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
For XHTML 1.0 frameset documents
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd”>
For XHTML 1.1 documents
Use this declaration
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN”
“http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
Options, options, so many options. If you want to start authoring web documents that are standard complaint, you can start nice and slow with XHTML transitional documents, but thats a whole other topic, stick around we will write about that also very soon.