To DTD Or Not To DTD . . . That Is The Question
Originally Published: 2001-07-16
Revised: 2006
The Internet provides us with easy access to information. We've come to expect that perk when we surf the Web. Over time, HTML expanded to not only present more markup elements but also the ability to bring in other components to the Web pages. With HTML 4.01, the advice is to start using what was once perhaps one of the least known or used markup.
With HTML 4.0, the HTML Working Group and W3C began advising people to use <!DOCTYPE="Document Type Declaration">, which is nicknamed DTD. Why?
The reason DTD is considered to be a more suitable and stable requirement relates to the various elements currently able to be used within an HTML document. Frames differ from Cascading Style Sheets and both of those differ from the basic style of Web Site presentation. Subsequently, W3C feel that the <html> is redundant and outdated due to the current versatility offered through HTML and components it can incorporate.
The W3C does realize that many Web Sites and Web surfers are still using HTML 3.2 (or older) software and/or browsers that do not recognize all the markup offered through HTML 4.0 or 4.01. What they are recommending is:
- Attempt to have your Web pages as compliant as possible to HTML 4.01, while considering HTML 3.2 thoughts . . .
- That you consider what type of Web design you are implementing through your HTML documents . . .
- Then seriously consider how to better inform browsers about those particular design thoughts or components. Especially as newer versions of browsers, software, and validations tools are introduced over time.
Makes sense, yet on the other hand how do you determine what your declaration is?
Reading the technical wording behind the types of declarations, some of us would be scratching our heads wondering if we should flip a coin. It would be easier in some instances to figure out our blood type than it would our HTML document's declaration flavoring.
This may explain why this particular HTML markup is rarely included on many Web documents. Some sources you may look to for reference may tell you to go ahead and skip using the DTD.
Yet, recall in the targeting of audience thoughts, your home page is becoming a Web Site that you want others to read and enjoy. The DTD is not solely about your HTML skills; it is taking into consideration that some of your reading audience may be using different means to read your Site. The DTD tells the browser what version of HTML you have used and how you applied it. In turn, the browser will be able to inform the person's software.
First step is deciding what way you will be using HTML within your pages:
- Strict: w3c's preferred one, when possible, for people to strive for within their Web sites' pages. Documents exclude presentation attributes and elements in the markup. So when using Cascading Style Sheets [CSS] scripting instead, as an example, here is your DTD.
- Transitional: Presentation attribute and elements used so support for those required. So if you have inserted attributes into some of your markup elements or using Java or JavaScript (not through a Style Sheet application), this is the type of DTD you will be using.
- Frameset: This is the HTML DTD, which should be used for documents with frames. This DTD is almost identical to the Transitional DTD except for the minor adjustments to make up for frames coding.
HTML 3.2
These are the ones I have seen the most often, when used that is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
HTML 4.0/4.01
Strict:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
Transitional:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
Frameset:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd">
XHTML 1.0
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0//EN">
Notation [June 2002]: Lately, some advice for those using CSS [Style Sheets] is to insert the DTD line but leave out the reference URL to W3C. This is felt to help ease some of the discrepancies certain DTD declarations may have with rendering Style Sheets properly. By placing this line, you can later insert the appropriate W3C reference URL.