Power To The People: Relative Font Sizes

Relative font sizes make websites more accessible and easier to read — but they’re not much help unless the person using the site can find a way to actually change text size. Internet Explorer, the most widely used browser, buries the option for selecting text size in a second-level menu, which makes text resizing a hassle and is too complicated for some users. On-site buttons that let people increase and decrease text size can make it easier for them to find and use the option.

Article Continues Below

Unfortunately, most existing methods for using resizing buttons ignore the user’s default settings. Here’s a simple solution for text resizing that respects users’ choices and also gives them an additional option for resizing.

The CSS#section2

The first step is to create a basic CSS file that uses relative font sizes in conjunction with default size. We can use percentages or em units.

/* default font size*/
@import url(small.css);/* Netscape 4 safe font sizes */
body, div, p, th, td, li, dd {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
}h1 {
  font-size: 130%;
  font-weight: bold;
}h2 {
  font-size: 110%;
  font-weight: bold;
}

Then we create five alternative style sheets using the absolute sizes that are defined in the CSS specification: xx-small, x-small, small, medium, and large. The scaling factor between the individual indexes should be 1.2, as suggested by the CSS2 specification. We should also consider and compensate for the size problems in IE5 and Opera (for details and explanation, have a look at Todd Fahrner’s great article, “CSS
Design: Size Matters
”).

/* xx-small.css*/
body,
body div,
body p,
body th,
body td,
body li,
body dd {
  font-size: xx-small;
  voice-family: ""}"";
  voice-family: inherit;
  font-size: x-small
}html>body,
html>body div,
html>body p,
html>body th,
html>body td,
html>body li,
html>body dd {
  font-size: x-small
}

The created files are: xx-small.css, x-small.css, small.css, medium.css, large.css.

The HTML#section3

Next, we create the HTML document and connect the basic and alternative CSS
  documents, giving the alternative style sheets names from the smallest, “A—”, through “A-”, “A”, “A+”, and “A++”. These names will be displayed in Firebird’s “Switch to alternate
stylesheet” menu and Mozilla’s “View > Use style” menu.

<link rel="stylesheet" href="style.css" <span class="linewrap">»
type="text/css" />
<link rel="alternate stylesheet" <span class="linewrap">»
type="text/css" href="large.css" title="A++" />
<link rel="alternate stylesheet" <span class="linewrap">»
type="text/css" href="medium.css" title="A+" />
<link rel="alternate stylesheet" <span class="linewrap">»
type="text/css" href="small.css" title="A" />
<link rel="alternate stylesheet" <span class="linewrap">»
type="text/css" href="x-small.css" title="A-" />
<link rel="alternate stylesheet" <span class="linewrap">»
type="text/css" href="xx-small.css" title="A--" />

The JavaScript#section4

Then we add the style-sheet switcher from “Alternative
Style: Working With Alternate Style Sheets
” to our HTML page:

<script
  language="JavaScript1.2"
  src="styleswitcher.js"
  type="text/javascript">
</script>   

The buttons themselves get implemented like this:

<form name="font_select" acti>
    <input
      type="button"       
      value=" font - "
    />
    <input
      type="button"       
      value=" font + "
    />
</form>

Here’s the style switcher source code, and here’s a complete working example, tested in Mozilla 1.6, Mozilla Firebird 0.7, Opera 7.11, IE 6 Windows, IE 5.2 Mac, and Safari 1.2. That’s it!

A warning#section5

Beware of the bug in IE which turns on quirks mode when the XML declaration
is positioned above the document type.

Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

73 Reader Comments

  1. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    Thanks for the article. It seems that this method could be upgraded furtherly, so the alternative stylesheets xx-small.css through large.css could bring additional benefits for the user. Like better contrast of text, if user choose a larger font.

  2. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    You can’t design for the “average user”, you have to design for the lowest common denominator in the audience you intend to reach. Targeting average users is one of the reasons we’ve ended up with web sites that only work in one browser. Designers said “Most people use Netscape so we’ll design for that.” Now that most people don’t use Netscape, all those sites, along with the techniques dreamt up implement them, are obsolete.

    Besides, the average user IS an idiot.

  3. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    I would add to Steve J’s list a certain enormous state university in Ohio, which is certainly not the only one in the US. Probably also any number of underfunded operations like public libraries and high schools still making due with 100mhz machines from the mid 90’s that can’t even fit the newest Netscape browser on their hdd.

    I agree that developing for NN4 is a waste of time and that anyone still using such browsers by choice is simply not interested in pretty layouts and non-default fonts, but developing in a way that actively excludes NN4 and other such browsers from accessing content is just taking the easy way out.

  4. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    Thanks for this information – particularly the style sheet hints.

  5. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    Why is it necessary to change an entire Stylesheet when you can just use DHTML to change the Stylesheet. I think we should allow the user to view the page in Plain Text. I added a plain text stylesheet to my history site.
    Opera 7.23 has a built in function that switches stylesheets, it’s under View > Style

  6. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    Two words: get Opera.

  7. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    I have both Opera 7 and Netscape 4 on my computer. Opera is great for older browsers (light), but people who use these old computers don’t have a damn clue what Opera is.

  8. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    In the article it said that the font-change option is burried far away in the menu. That’s true, but don’t forget those who have a mouse wheel. If you press CTRL and scroll your mouse wheel, a *good* webpage will size the fonts bigger and smaller on IE and Opera. On Netscape use CTRL and the + and – keys on the numkeypad.

  9. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    Thank you for the good idea.

  10. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    When I try and change the input type to image I get an error can’t find /GET

    Works fine when I use “button” but not “image” what am I missing??

  11. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    Up until recently, I had an old computer at home which could only run NN4, IE5, and iCab. NN4 was the closest to the functionality I wanted, so that’s what I used. If I couldn’t use it on a site, I normally never went back to that site (which would of course, if others did so as well, lead to lower numbers).

    Now that I have a newer computer, I’m on Mozilla 1.6. People who use older browsers may not have a choice (my case) or may now know how to download a new browser. And the few who are on MSNTV (formerly WebTV) don’t have a choice.

    Anyway, there is a difference between catering to NN4 (what we have done in the past), being NN4 tolerant (what we will be doing with the next technical redesign of our site)and NN4 hostile (which we won’t do because we’re a public agency and try not to annoy people).

    Back to the article itself:

    As for duplicating browser features, the average user is not familiar with those features. We’ve gotten multiple complaints about people not being able to zoom PDF maps we’ve published; zooming is a built-in feature of Acrobat Reader. If it’s not out in front of them on the Web page, they often won’t know it’s there.

  12. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    thanks for this peice. I’ve just been struggling with fonts and this helped out quite a bit.

  13. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    I experimented with your code and all works fine.
    I prepared five stylesheets with only the initial font-size settings, and a single stylesheet with all other classes definitions, with relative dimensions.

    With Mozilla 1.4 I need to reload the page after a size change, so I added the following:

    window.location.href = window.location.href;

    at the end of both functions fontsizeup() and fontsizedown() and all works fine.

    Thanks!

  14. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    Hi

    Using CSS you can actually fool the Search Engines. Which is kinda Unethical. You can show an H1 tag smaller than a normal size font using CSS.

    SEO India

  15. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    I’m not usually so pernickity, but I happened to be reading the 2.1 recommendation and they’ve changed the scaling again. It differs for each step now to be more usable.

    http://www.w3.org/TR/CSS21/fonts.html#font-size-props

  16. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    The example is outstanding. Trouble is, I’m a novice. At first, the instructions sounded like you plug in the script and you’re set to go. That sounds too good to be true, even to me. But what if you don’t now how to work with css? Anyone know a company who might volunteer to add this feature to a charitable organization’s website for the disabled community?

  17. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    Relative font sizing rocks. Personally, I try to use ems or % rather than keywords, but I can see there are circumstances in which keywords are better. Good article.

  18. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    Another wicked article

  19. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    Ok, that’s nice, but…. It weren’t better to instruct two diferent sizes limit according to the screen res?
    If people have, say, a 800X60 res, and swaps size ’til the max size, it gets a very bad layout.
    Urges a script that manages this:
    if I have the screen set to 800×600, so the max size is this (say, from 8px to 11px); if it is upto 1024, it is that (say, from 11 to 15 px).

    It is more reasonable and elegant, I guess.

  20. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    I think everyone should be given the oppurtunity to resize their font. What if is to small or to big. It should be easy to resize font also. Give them some choices. you never know who is reading anything.

  21. Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

    I’m a bit confused, and after a testing, even more confused. Why has the author chosen to declare font-size in this manner:

    /* xx-small.css*/
    body,
    body div,
    body p,
    body th,
    body td,
    body li,
    body dd {
    font-size: xx-small;
    voice-family: “”}””;
    voice-family: inherit;
    font-size: x-small
    }

    Wouldn’t the following be enough?

    body { font-size: xx-small }

    With the latter, everything in the body now is xx-small, no? From my testing, the author’s code actually causes some inherietance problems. Is there a point that I’m missing in writting it out the way the author has here?

Got something to say?

We have turned off comments, but you can see what folks had to say before we did so.

More from ALA

Designed for a Dead Language

Every language app in your pocket inherited a teaching method built for Latin. Understanding why that happened is a more useful design lesson than anything the apps themselves can teach you.
Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

Good designers, bad websites: a proposal

Designers are good people. Some designs exclude people anyway. Alan Dalton offers a practical fix: accessibility personas that help you recognize problems while you're designing, not after. Homework included.
Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

Design for Amiability: Lessons from Vienna

Computing was born in a Viennese café. Between 1928 and 1934, while Hitler plotted and Europe crumbled, a motley crew of mathematicians, philosophers, architects, and economists gathered weekly to puzzle out the limits of reason—and invented Computer Science in the process. What made their collaboration possible wasn't just brilliance (though they had plenty). It was amiability: the careful design of a social space where difficult people could disagree without destroying each other. Longtime Web Dev Notes contributing author Mark Bernstein mines this forgotten history for lessons that might just save today's embattled web from its worst impulses. Spoiler: it involves better coffee service and the looming threat of public humiliation.
Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker

Design Dialects: Breaking the Rules, Not the System

Design systems aren't component libraries—they’re living languages. Rigid adherence to visual rules creates brittle systems that break under contextual pressure. Fluent systems bend without breaking.
Web Dev Notes Proxy © 2026 | Powered by Cloudflare Worker