“Transitional” DOCTYPE Considered Harmful

Posted in Web Development with tags , , , , , on March 6, 2011 by Carl Tessier

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

Some Web developers giggle at this line. Some others wonder “What? What is wrong with it? I’ve been using it ever since I started and it works!” If you belong to that second category, you either don’t know what this line does, or are too lazy to make your site standards-compliant.

For those who have always been wondering what this line does, a DOCTYPE declaration tells the browser what type of document it is receiving (obviously), and which version of that type. For example, the one at the top of this article would be at the beginning of a document using HTML version 4.01 Transitional. And it’s in English. The version distinction (here, “4.01 Transitional”) is important, because, as we will see, they are not always compatible with each other. Oh, and by the, way, the DOCTYPE declaration is required. Always.

“Transitional” Is a Relic of The Past

See, once upon a time, there was HTML 3. It was a pretty limited format designed for on-screen documents. It did not allow for global style declaration (except maybe for <basefont>), every font style had to be declared on the spot. If you are knowledgeable in text processing, then you know it is a no-no.

And at that time, the few different Web browsers pretty much interpreted the HTML language their own way; and worse, none of them were totally right. This made for sites “Designed For Internet Explorer” or “Designed For Netscape”, and sometimes, they even were designed for a particular version of a browser. Some browsers went so far as to define custom, proprietary elements that were not part of any standard. And websites used them at the time.

Then, in late 1997, came HTML 4, which introduced a lot of improvements. Among them was the fact that the HTML document could only contain the actual content of the page. The presentation (that is, font styles and colours as well as layout) was to be put a separate file in a newly introduced format: Cascading Style Sheets (or, in short, CSS). The HTML tags and attributes that affected the presentation, such as <font>, <u>, <strike>, <center> and align officially became obsolete. Strictly speaking, HTML 4 was therefore not backward compatible with HTML 3.

As you can imagine, not all Web developers had enough time on their hands to recode their site into valid HTML 4, so they made a special version of it, which they called “Transitional”, and which still allowed those old deprecated constructs from HTML 3, but also allowed that new stuff from version 4 such as CSS and logical styles. As the name implies, it was designed for the transition to HTML 4… in year 1997.

At the time of writing this, we are in year 2011, a bit more than thirteen years later.

XHTML 1 Transitional was also designed to allow old HTML 3 constructs. I don’t even know why it exists.

What you should be using by now (and, actually, many years before) is this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
or
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Using an older version or a Transitional version is no longer justifiable and will make you look like a n00b, or arguably worse, a jerk. Even if your WYSIWYG editor (such as Dreamweaver or Expression Web; they’re known to be foolish like that) defaults to that, change it.

I’ve been asked “So yeah, why does it matter anyway? My page still works!”

“Transitional” Makes Your Page Look Crappy

At the beginning of this century, two things happened:

Web designers and developers started trying to make their site work properly across all browsers instead of just one, and Web browser vendors realized what kind of a headache that was, and started to actually give W3C’s recommendations some attention. In other words, standards compliance became a marketing tool for browsers.

As a result, many developers also started coding their site according to W3C’s recommendations instead of using browsers’ proprietary constructs.

However, changing a browser’s behaviour to be standards-compliant has the costly price of breaking old websites that were relying on old browsers’ quirks, so they added some heuristics to detect if they were looking at an old page, or a newer, probably more standards-compliant one: If the page is using an old version of HTML, or a Transitional one, then it must certainly be an old page. This has the effect of putting the browser in “Quirks Mode”, which emulates an old, non-standards-compliant browser. The lack of a DOCTYPE declaration also throws the browser in Quirks mode, since a page lacking such a required declaration certainly isn’t standards-compliant.

A quirky rendering engine means that your code will have unexpected side effects, especially in terms of layout. This means that you’ll have to figure out some extra hacks to make it work properly. And worse, since old, quirky browsers all interpreted HTML and CSS in different ways, Internet Explorer’s Quirks mode will indeed be different Firefox’s… so there will have to be even more hacks to work around those differences. All of these hacks could be avoided simply by using a non-transitional DOCTYPE!

Still, Web developers keep using Transitional HTML, over ten years after the transition it refers to should have ended!

One of my clients had me fix a layout issue on their website, and even after I fixed the mess, the result was not consistent across browsers because the page did not only use, but actually relied on the browsers’ Quirks modes, because the original developer had mindlessly let Dreamweaver put in a Transitional DOCTYPE.

So, please, never use Transitional ever again. You and your visitors will both benefit of this. It will prevent weird side-effects from happening, and make your website work much more consistently across different browsers.

You know that a security suite is bad when…

Posted in Tech Support with tags , , on August 20, 2010 by Carl Tessier

…it wreaks more havoc into the system than the viruses1 themselves.

One of my clients called me because of a problem he had with Windows Mail, and also one he had with CuteFTP (which he uses to update a weekly journal on his website).

So, upon arrival I was told that he went to a certain large store to have other problems fixed, and for some reason, the techie there decided that his Avast! Free Antivirus (which I installed myself) was an expired trial version; he uninstalled it and installed Norton Internet Security instead. (And charged $80 for the piece of software and $20 for the installation “labour”.)

Anyways, the problem was: Windows Mail wouldn’t start. After doing a quick check in the Task Manager, I figured out that there was an instance of it still running, and wasting CPU cycles. Since it is a single instance application (it checks if it’s already running as you launch it, and if it is, it just sets the focus on the main window of the existing process) and that its window has been closed, it made sense that it refused to start.

So I killed the process, and launched Windows Mail again. It worked flawlessly. I closed the window… the process hung in there, and took 100% CPU again.

The only configuration change the computer had since last time I saw it was… you guessed it… Norton Internet Security. Launched Process Explorer, checked the DLLs loaded by the process… yup. Norton had a shitload of DLLs hooked onto Windows Mail.

Disabling the anti-spam filter and e-mail scanner (after not listening to Norton telling me it’s a very bad thing to do) didn’t help. It kept hijacking Windows Mail… and re-enabling itself without telling me, even if I told it not to. And Windows Mail just wouldn’t die when I closed it.

Uninstalling the Norton Internet Security Suite magically fixed the problem, so it was the culprit anyway. A $80 (+ subscription fees) piece of garbage that made the computer (at least a part of it) malfunction more than anything.

I had my client fish out the work order from that large store from his papers, and attached a nice letter explaining what Norton was doing to his system… and I reinstalled Avast! Free and re-enabled Windows Firewall.

As for CuteFTP, I don’t know what the problem was exactly, but it didn’t happen again. Something tells me that Norton was blocking it, silently.

Extra WTFery

The guy from that large store also told him that his computer was short on RAM. More than half of its whopping 2 GiB was free (he only really does e-mail reading and text processing) all the time I was there.

Also part of what an antivirus shouldn’t do is nag the user each time they logged in that they didn’t register the product by sending them their e-mail address. Or nag the user that one useless (and more importantly, buggy) feature of the “security suite” is disabled, as if it was extremely important and they did not know what it implied. Norton did all of that. And it was not possible to disable that.

1 In proper English, it is “viruses”, not “virii”. Don’t bug me with that, please; check your dictionary instead.