Re: css font question

by Andrew McFarland <aamcf(at)aamcf.co.uk>

 Date:  Sat, 03 Aug 2002 19:18:17 +0100
 To:  "Basics List HWG (E-mail)" <hwg-basics(at)hwg.org>,
"List HWG Techniques (E-mail)" <hwg-techniques(at)hwg.org>
 In-Reply-To:  umr
  todo: View Thread, Original
At 09:18 03/08/02 -0500, Hall, Richard H. wrote:
>1) Simple question: When you list a number for font size, what default 
>measurement unit does the browser use?
>
>e.g. font-size: 24;

As others have said, this is invalid. You need a unit after the number. 
Some browsers may eg, assume you mean 24px, but you can't rely on this.

>2) Bigger Question: I notice that increasing or decreasing the font size 
>in the browser (e.g., changing to large font under view in IE) does not 
>effect font size when I use px or pc or pt ... it does, however, seem to 
>work when I don't specify a measurement unit and when I use em ...
>
>... I think I understand with pixels, in that you couldn't change the 
>pixel size without changing resolution, but I don't understand why this 
>would not work with pc or pt and,

pc and pt are also physical sizes - IIRC one pt is about 1/72 of an inch. 
The computer sets the display to show x pixels per inch, so pc and pt can 
be translated into actual pixel sizes. That's why you can't (easily) resize 
font set in pt or px.

>of course, this brings up the biggest and probably most difficult 
>question, which is what measurement is best to use?

For the main font on the page always leave it unset[1]. That way the base 
font is set to the correct size for the end user, and it can be easily 
resized by the user if necessary.

The best unit is either em or %, which are essentially the same thing (100% 
is essentially the same as 1 em). These work well in modern browsers and 
are easily scalable.

px is only useful when you have to have an absolutely pixel-perfect layout 
_and_ you know the display settings of the machine it is being displayed 
on. px can't be easily resized, which is a serious problem.

[1] <rant>Unless you have an obnoxious client or boss who wants you to do 
otherwise</rant>

Andrew

--
http://aamcf.co.uk/

HTML: hwg-basics mailing list archives, maintained by Webmasters @ IWA