Setting font size in pixels

A long, long time ago, Jeffrey Zeldman said Give me pixels or give me death in the A List Apart article Fear of Style Sheets. The point Jeffrey was making is that using pixels was (and still is) the only way you can specify font size on the web with any kind of certainty. All other units will result in text that varies in size depending on a lot of factors.

So why are we not using pixels to specify font size? Mainly because of Internet Explorer for Windows. Many web users (including myself) find the 9px text size that was so common at the end of last century impossible or very uncomfortable to read. All modern browsers allow the user to easily increase (or decrease, if that should be needed) text size. Except for one. Internet Explorer for Windows is the only browser that does not let the user change the size of text that has a font size set in pixels.

That leads me to Robert Nyman’s post Web browser vendors are also responsible for accessibility. Very true. There are many accessibility and usability issues that web browser vendors can help us with, and text size is one of them.

Wouldn’t it be nice if all web browsers could agree to allow the user to resize text, no matter which unit is used to specify its size? No more guessing, calculating, and hoping to avoid triggering rounding errors. No more font-size: 76% and font-size: 0.94em.

To avoid causing readability issues for those of us who need larger text, browsers should of course only use the number of pixels specified in the CSS unless the browser’s default text size has been changed. Designers and developers could still use ems for other measurements, like column widths, padding, and margin, to keep line length and whitespace within reason.

I’ll admit that I haven’t thought about this in depth, but it seems like a good idea. Does anyone see any potential problems that would make using pixels for text size a bad idea even if all browsers allowed their users to resize text specified in pixels?

Unfortunately, I am not expecting the release of Internet Explorer 7 to fix this bug. I can’t find a reference for it right now, but I have a vague memory of reading that Microsoft for some reason beyond comprehension doesn’t consider Internet Explorer’s refusal to resize text set in pixels a bug. I’m not particularly interested in buying a separate license of Windows XP just to test this in the recently released IE7 Beta 2 Preview, so I can’t confirm if it behaves the same way as older versions of IE/Win.

Unless I’m wrong about that (which I do hope I am), web designers and developers will have to keep fighting rounding errors, using odd values, and always keep inheritance in mind when specifying font size for the websites we create.

Posted on February 1, 2006 in CSS, Browsers, Accessibility, Typography