tags:

views:

113

answers:

4

In HTML/CSS font size can be specified in the following fashion (deprecated but all browsers support it):

<font size="n">text</font>

with n an element of {1, 2, 3, 4, 5, 6, 7}.

Another possibility is the following:

<span style="font-size: s;">text</span>

with s an element of {xx-small, x-small, small, medium, large, x-large, xx-large}.

Is there any de-facto relation between the two ranges? I figured they refer to the same sizes, as they have both seven elements, but that turns out not to be the case.

A: 

I think the (recommended) scaling factor between sizes is 1.2. CSS doesn't require a scaling factor.

John at CashCommons
+1  A: 

Short answer: No, it's browser specific. There's no standard mapping between them.

Long answer: check this document as it is discussing the same issue in details.

Aziz
+2  A: 

Please don't use either of those methods for specifying font-size. They were deprecated for good reason. It is nigh-impossible to create a consistent look and feel across platforms using the methods you described -- not to mention that you become completely dependent on the browser vendors for what they specify as the values for each of these.

Instead, use ems or percentages. You will get a much more consistent appearance, as well as having much finer control over the sizes of fonts your design demands.

bigmattyh
Even better, use pixels (px). You probably already use pixels for sizing everything else (boxes, borders, etc.) anyway, so your fonts will be the same size relative to the other page elements across platforms. (And if you're using a PC, please keep body fonts above 12px so us Mac users can read it).
Seth
I am not using any of the methods I mention myself. I am asking because I need to recognize font size in other peoples' HTML, and I am trying to unify as much as possible.@Seth: I am not a big fan of px. Instead I generally try to define as much as possible using em (including dimensions, padding, margin, sometimes even borders). My experience is that the more you define using relative measures, the more flexible you keep your lay-out, the more compatible it is over various platforms, and the more (resizing) power you leave in the user's hands.
Tim Molendijk
@Seth - your comment shows exactly why you shouldn't use px: "and if you're using a PC, please keep body fonts above 12px so us Mac users can read it". If you want a truely accessible site, em's are the way to go - there's plenty of stuff out there about getting a consistent sizing across browsers and platform by specifying a base size in the body, and then em's from there.
Zhaph - Ben Duguid
+1  A: 
Zhaph - Ben Duguid