One of the things that constantly amazes me, is the number of brand new websites built using a Transitional DOCTYPE. Has the Transitional DOCTYPE had its day?
Author: Gez Lemon
- Document Type Definitions
- Brief History of Markup Specifications
- Using a Transitional DOCTYPE on Today's Web
Document Type Definitions
Each element in a markup language has a relationship with other elements within that language. The relationship between the elements defines the structure of the data. A Document Type Definition (DTD) provides a formal definition of the elements and associated attributes for the document structure. A DOCTYPE is a statement that should be included at the top of your documents identifying which DTD you are using. The W3C defines several DTDs that may be used for publishing documents on the Web. The two most common factors when deciding on a DOCTYPE are:
- XHTML or HTML
- Strict or Transitional
HTML 4.01 is the last version of HTML defined by the W3C. There will be no more versions of HTML, as it has been superseded by XHTML. HTML is still a valid standard, and due to the number of HTML documents out there, will be around for many years to come. Because of the poor support for XHTML in the current version of Internet Explorer, undeniably the most popular browser around today, HTML 4.01 is still a good choice for content developers. XHTML has the advantage that the markup must be well formed, and can be loaded into an XML parser to manipulate the document. Is there a reason to use XHTML if you're not using XML tools? The transition from HTML Strict to XHTML Strict is merely a case of making sure the document is well-formed, and changing the DOCTYPE. In short, there's no advantage to using XHTML on today's web.
Brief History of Markup Specifications
HTML 3.2 was an official W3C recommendation in January 1997. The first official W3C recommendation for HTML 4 was published in December 1997, and went through several revisions until the final version (HTML 4.01) was published in December 1999. The first working draft for the reformulation of HTML in XML was released in December 1998. XHTML became a W3C recommendation in January 2000, and was revised in August 2002. At the time, there was a lot of legacy markup around, and they needed a DOCTYPE that would allow developers to move to newer standards without breaking what they already had. The solution was to provide a Transitional DOCTYPE. An HTML Transitional DOCTYPE allows developers to make a transition from HTML 3.2 to HTML 4.01 with minimal impact on what they already have. Developers can then amend the code, until they're able to work with the Strict DOCTYPE, which deprecated a lot of the presentational elements and attributes, aiming to separate presentation from content. An XHTML Transitional DOCTYPE allows developers to make a transition from HTML 3.2 to XHTML 1.0, with the same benefits as those making the transition to HTML 4.01.
Using a Transitional DOCTYPE on Today's Web
There seems to be a common misconception that the XHTML Transitional DOCTYPE is for developers to make a transition from HTML 4.01 to XHTML 1.0. It's utter nonsense, as the HTML 4.01 DTD and the XHTML 1.0 DTD are very similar in the rules they apply. The only difference is the well-formed issues that any XML application must adhere to, whether it's Transitional or Strict. So which is the better DOCTYPE? HTML 4.01 Strict, or XHTML 1.0 Transitional? Without a shadow of doubt, the HTML 4.01 Strict DOCTYPE is a far better than XHTML Transitional, as it deprecates presentation elements such as
font, and presentation attributes such as
align. XHTML Transitional merely means you've ensured it's well formed.
The HTML 4.01 Transitional DTD states:
This is the HTML 4.01 Transitional DTD, which includes presentation attributes and elements that W3C expects to phase out as support for style sheets matures. Authors should use the Strict DTD when possible, but may use the Transitional DTD when support for presentation attribute and elements is required.
With this in mind, I'm amazed at the number of brand new sites, or even well maintained sites with a Transitional DOCTYPE. Why on earth, in 2004, would developers be using parts of a specification that were updated well over 6 years ago? Whenever I ask developers this question, the stock response is, "XHTML Transitional is a valid standard". And of course, they're correct; it is. And so is HTML 3.2, so why haven't they chosen that DOCTYPE, and enjoy the thoroughly legal mixture of presentation and content elements/attributes? Another common response is that XHTML Strict should be delivered with the correct MIME type. But so should XHTML Transitional. If you're going to ignore the advice completely, ignore it using the Strict DOCTYPE. The only XHTML version that the W3C recommend *should not* be served as
text/html is XHTML 1.1. Some developers are prepared to ignore that too, as *should not* is not as serious as *must not*.
If you use an XHTML Transitional DOCTYPE, ask yourself why. If you're honest, the answer will either be because you can't live without the presentation elements that a Transitional DOCTYPE affords, or because you want to launch new windows. Launching new windows is a whole new subject, but I'll briefly mention that the user interface isn't part of your document, and should be left to your visitors to decide where they want links opened. It's time to move forwards.