[thelist] Fraction/decimal in CSS font size - Can you confirm?

Bill Lovett blovett1 at rcn.com
Sun Oct 21 23:41:40 CDT 2001


On Mon, Oct 22, 2001 at 10:56:55AM +0700, Uman Madiprasojo wrote:

> with 10px. Here's the punch: when I entered 9.5px size, it looks the
> exactly same in IE and NS (now there's a tip!). 

That's pretty cool, although kludgy. It looks like Explorer rounds
down to 9px, but Netscape rounds up to 10px which is really 9px unless
you, like Netscape, choose to live in the parallel universe where
everything is 1 size off.

> The question is: Is there any warning of using fraction/decimal/unround
> numbers in CSS font size?

Probably not a good idea if you use pixels as your unit, but why not
if you're using a relative unit like em. If you use decimal numbers
with pixels, you'll probably tear a hole in the space-time
continuum. And then everyone will say it was your fault.


> I might do a javascript eval
> procedure identifying browser and then specifying which size I should
> set but that would render the page useless with the JS off. Please
> advise. 

A non-javascript solution is to use 2 style sheets. The first one
specifies 10px and is included on your page via a <link> tag. The
second stylesheet is right underneath and is included via an @import
command inside a <style> tag. This stylesheet redefines the class or
id with 10px. Netscape 4 ignores the second stylesheet complete
because it doesn't understand @import. Just about everyone else does,
though.


-bill




More information about the thelist mailing list