There are many different Document Type Definitions that you can use on Web pages, but how do you choose the best one for your Web page? This list will detail some of the common DOCTYPEs and what Web pages they generate.
HTML 3.2 Is the Oldest DOCTYPE You Should Use
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
This doctype indicates to the browser that the HTML generated will be HTML 3.2. HTML 3.2 is about the oldest specification of HTML that you should be using. It is very basic HTML and most browsers will support it. But it doesn't support some of the newer features of HTML like frames. I recommend using this for pages that are being used for cell phones or other really basic sites.
HTML 4.01 Transitional - Safe for Most Browsers
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
The HTML 4.01 Transitional DOCTYPE is probably the most popular DTD out there. It gives you the older deprecated tags like font that are no longer part of the strict specification. It tells browsers that you are using the most up-to-date HTML, but need some backwards compatibility. I recommend this DOCTYPE if you are updating older pages to use the new version of HTML.
HTML 4.01 Strict DOCTYPE is Harder to Implement
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
HTML 4.01 Strict removes all the deprecated tags from the specification. Be careful whenever you use strict DTDs to validate your HTML and ensure that it's correct. Strict DTDs are great for being absolutely correct against the standard, but not all browsers handle the alternatives to tags that are missing.
HTML 4.01 Frameset DOCTYPE is for Frames
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
If you're using frames, you must use this DOCTYPE or the XHTML Frames DOCTYPE listed below. Otherwise, your pages won't validate.
Quirks Mode
Quirks mode is generated when you either use the HTML 4.01 Transitional Doctype, you don't define a Doctype, or you use a doctype without a URL DTD defined. For example, Internet Explorer changes how the pages are displayed if you remove the DTD from the Transitional Doctype:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
XHTML DOCTYPES
Because XHTML 1.0 is a re-rendering of HTML 4.01 into XML, it has the same three DOCTYPES: transitional, strict, and frameset. Deciding to use an XHTML DOCTYPE should be based upon how you'll be working with your pages. XHTML gives you more ability to program pages, but it has a lot more room for error. In order for an XHTML document to validate, all the tags must be closed, attributes quoted, and all tags written in lowercase. If you don't do any one of those things, you should consider staying with one of the HTML 4.01 DOCTYPEs. But if you're using scripting or back-end programming to work with your Web pages, then moving to XHTML is a good plan. Use the same rules as above for deciding between the different XHTML DTDs.
Remember that XHTML is an XML document, so you should include an XML declaration above the DOCTYPE:
<?xml version="1.0" encoding="UTF-8"?>
XHTML 1.0 Transitional
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
XHTML 1.0 Strict
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
XHTML 1.0 Frameset
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
More Advanced DTDs - XHTML 1.1, HTML 5.0, XHTML 2.0
If you really want to branch out and build Web pages that are ahead of the curve, then you can consider using these DOCTYPEs. XHTML 1.1 takes XHTML 1.0 and modularizes it. This makes it possible to define only the tags you want supported on the page in your DTD. XHTML 1.1 is very similar to XHTML 1.0 Strict, but it avoids many of the presentation features.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
HTML 5.0 is a conglomeration of Web Applications 1.0 and Web Forms 2.0. It was developed to try to address the needs of content authors and continue moving HTML forward, rather than worrying about whether it is valid XML or not. It is supported by browser manufacturers like Apple, Mozilla, and Opera. The DOCTYPE you use is very simple, just:
<!DOCTYPE html>
XHTML 2.0 is a new version of XHTML that is not intended to be backward compatible with XHTML 1.1 or HTML 4.01. Right now it has limited support from Web browsers, but if you were going to use it, you could use the DOCTYPE:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 2.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml2.dtd">

