HTML Transitional What? | The Ins and Outs of HTML Document Type
May 26th, 2008 in Design Tips & Tutorials
by: Matthew Griffin
There's a divisive little tag at the top of every web page called DOCTYPE. It's not divisive because web designers disagree about what should go in that tag or which doctype should be specified (although they argue about that too). It's divisive because half of the web designers barely give a thought to it and the other half would die a bloody death for what's in that tag. Whatever category you happen to fall in, I think you'll appreciate this concise guide to HTML DTDs. Every designer should know the basics and make an informed decision about doctype.
I'm primarily grouping the DTDs by transitional and strict. This seemed like the best route since the differences between HTML and XHTML are pretty simple compared to the differences between transitional and strict. Essentially XHTML is a lower-case, well-formed version of HTML. It comes in handy if you ever want to suck a web page into an XML parser.
It may interest you to know, though, that there will be no more versions of HTML released in the 4.0 series, so XHTML is probably the direction you should be headed (Check this article out if you want to start converting to XHTML). HTML 5 (currently in development), introduces a new spec that will allow both XML and HTML serialization but will significantly change the semantic quality of the markup overall. I won't get too deep into that here but A List Apart has a great article previewing HTML 5 if you want to know more (Thanks to Ville Väisänen for turning me onto the link). Other than that, they're pretty much the same. Okay, let's move on to the complicated stuff.
Transitional Doctypes
HTML 4.01 Transitional and XHTML 1.0 Transitional
The transitional DTDs were developed to help web designers make a gradual transition from HTML 3.2 to HTML 4.01 and XHTML 1.0. Technically, they were meant to be used only temporarily while HTML markup was brought up to the current standards. Since HTML 4.01 and XHTML 1.0 required that all presentation be separated out from content, presentation tags like <font> and <u> were not to be used. Instead, CSS was to be used to add all style to content. But many legacy websites still had the old presentation markup and they needed a way to make the transition gracefully. Here we are, though, eight years after the transitional DTDs were released, and many web designers are still using transitional Doctypes (Myself included).
Standardistas frown on the transitional doctypes and I understand why. The transitional doctypes allow designers to be loose with content/style separation. I believe strongly in this separation but when you're designing in the real world for real clients, there are some cases where it can be difficult. Don't get me wrong, it's not impossible. But I think it's important not to over-complicate something that was originally meant to simplify. I already know I'm going to get into trouble for saying that so go ahead and comment.
Strict Doctypes
HTML 4.01 Strict and XHTML 1.0 Strict
As I mentioned above, the strict DTDs enforce a high level of content/presentation separation (I didn't mean to make that rhyme). The strict doctypes disallow a number of presentation element from HTML 3.2. The illegal tags include the following:
- basefont
- applet
- center
- font
- iframe
- isindex
- menu
- u
- s
- strike
Attributes that are disallowed include the following:
- align (allowed on col, colgroup, tbody, td, tfoot, th, thead, and tr)
- background
- bgcolor
- border (allowed on table)
- height (allowed on img and object)
- hspace
- name
- noshade
- nowrap
- target
- text, link, vlink, and alink
- vspace
- width (allowed on img, object, table, col, and colgroup)
All in all the strict DTDs force good standards and well-formed markup. My hat is off to those of you who use a strict doctype on all of your sites.
It may be hard to believe, but that's pretty much it. When I was doing research for this article, I found several doctype guides that were easily four or five times as long as this one. Writers who take on this subject tend to do so for philosophical reasons which leads to long paragraphs about the history of DTDs and the evils of the transitional doctypes. This guide, on the other hand, should give you concise look at the practical use of doctypes. I'll save the esoteric pondering for another day.
- 11 Comments
- 4575 Views
Comments
Posted By: E. I. Sanchez on 05/26/08
Matt, What's the difference between : The illegal tags and disallowed ones? by the way, this has been very informative. I usually just copy & paste and don't really know what I'm using. Until now.
Posted By: on 05/26/08
Thanks, Edgar. The first list of illegal tags are actual HTML tags like <div>, <span>, etc. The second list are tag attributes like <body background="back.jpg"> (background being the attribute). Hope that makes it a little clearer.
Posted By: suraj naik on 05/26/08
surely..the strict DTDs makes you right a cleanest markup...those who wants to be an expert in CSS can use these for practicing, because you are not allowed to use align"" attributes usually & which makes completely dependability on css..believe me, this is the way how i conquered css..
Posted By: Ville Väisänen on 05/27/08
Hi Matt! You said "It may interest you to know, though, that there will be no more versions of HTML released after 4.01"... so what's up with HTML 5.0? work in progress... http://www.alistapart.com/articles/previewofhtml5
Posted By: on 05/27/08
Ville, yeah, I probably should have explained that in more detail. The original plan was to cut off development of HTML altogether and stick with XHTML only. The HTML 5 spec, although it is still called HTML, allows for HTML and XML serialization and syntax. I will add an update to the article explaining this.
Posted By: Mat on 05/30/08
Nice one Matt. Good article explaining the simple difference that a lot of designers can get confused over (or don't even check!). Interesting that the <u> and <s> tags are disallowed, yet <i> is still viable...
Posted By: Tom Bland on 07/04/08
Thanks for the post, Matthew. I'm just getting into the CSS/XHTML game, and have been told that the Strict XHTML DTD doesn't allow inline Javascript operators. Is this so? If so, it may be a key reason to use the Transitional DTD.
Posted By: Matthew Grffin on 07/07/08
Using inline javascript in strict XHTML documents can be tricky but it's not impossible. You will need to comment out the code correctly to make it validate.