CodeBitch : click here to go to MacEdition Homepage

Ditch the FONT tag already!

3 July 2000

If you’re wondering why a web site is slow to load, and there’s not some stupid Flash animation in the ad banners, suspect the FONT tags. If you’re wondering why it takes so long for you to make changes to your web site’s look and feel, suspect the FONT tags. Inline formatting is dumb. The FONT tag is dumb. It’s time web builders got rid of it.

The problem with the FONT tag is that you have to put it in every time you want a piece of text in a web page – talk about code bloat. The W3C deprecated the FONT tag in the HTML 4 standard with good reason.

The FONT tag is completely unnecessary. Almost everyone is using a browser that’s capable of at least some Cascading Style Sheet attributes. The ones that aren’t are either text readers like Lynx, for which that kind of formatting is irrelevant, or pre-release browsers like iCab, which promises full CSS1 support for its final release. Oh, and OmniWeb, the NeXt-born browser for Mac OS X. (So much for the superiority of the APIs resulting in superior products.) Netscape 3.x doesn’t support CSS, but considering how long Version 4 has been out, if you haven’t upgraded, I say serves you right.

Sure, Netscape 4.x has really doggy CSS support. It sucks the big one. I’ve got several more columns in me on that topic alone. But the CSS it does support just happens to include all the things you can do with a FONT tag – size, bold, italic, typeface and color. Same with IE 3.x, if anyone is using that piece of outdated junk anymore.

If you do nothing else, make a stylesheet for your fonts. You don’t have to do clever CSS-Positioning. You don’t have to know JavaScript. Just a few sizes, colors and typeface families.

For example, suppose you want all your second-level headings to be dark red, Arial and a bit bigger than the default sizing of the browser. Then you’d use:

H2 {font-family : Arial, Helvetica, sans-serif;
	font-weight : bold;
	color : #990000;
	font-size : 110%;}

And if you decide next week that you want a slightly brighter red, you don’t have to edit every single instance of an H2 in your page. If you use a linked stylesheet, you only need to edit one line of text, instead of doing a search and replace over your entire site.

Why is this so hard to understand? It’s not as if the peculiar attachment to the FONT tag is because people want to be backwards compatible with as many browsers as possible. These are usually the same designers that litter their pages with a hundred flaming JavaScripts – and we all know how compatible that can be. Or they make it hard for browsers by writing code that isn’t correct HTML. No wonder browsers are so bloated – it’s all the error-catching code.

A lot of people seem to persist with bone-headed FONT tags because they want to have the hyperlinks in their sidebars to be a different color, typeface and size from the hyperlinks in their body text. Well, hello, use a class attribute. It’s not as if class="mysidebar" is more typing than <font face="Geneva, Arial, Helvetica, sans-serif" color="#ffff33" size="2">...</font>.

Another reason that FONT tags persist is that various automatic code generators have never been designed to write correct code. Whether it’s WYSINWYG web page editors like FrontPage or the myriad of Perl scripts and server add-ons written by third-party developers, FONT tags and incorrect HTML abound. Case in point: go to any news site that has filenames that look like 01,2344,303434343.html (News.com, ZDNet and Wired are all examples). Have a look at the source code for those pages. You’ll see lots of FONT tags and also lots of comments with extra hyphens in them (which is wrong).

Don’t you think that the developers who publish software that purports to perform automatic web publishing would have a clue about HTML? It seems not. Stupid brain-dead browsers end up interpreting stupid incorrect or bloated HTML markup. And this is meant to be the spark for the new economy?

It’s not even as if my opinions on the FONT tag are particularly new or controversial. The real web gurus have been saying it for years. So what’s with everyone? How come “Internet time” doesn’t apply to the way people write HTML? Let’s let the FONT tag die the death it deserves.

— CodeBitch (codebitch@macedition.com) is the grumpy cow who does the HTML production for MacEdition.

E-mail this story to a friend