July 17, 2010

Why are the font sizes different

Question by Mark0978

I’ve got the following html and css
In Firefox the computed font size is 16.66667px
In Chrome the computed font size is 13px

Needless to say there is a good bit of difference in these two sizes, one is too small to read, one is nicely sized. I guess one way to work around it is to set the font size to 16.67px but why is this the case.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
  <title>My first styled page</title>
  <style type="text/css">
    body {
        font-family: Arial, sans-serif;
        font-size: 10pt;
    }
  </style>
</head>
<body>

    This is some text.
</body>
</html>

All my measurements come from inspect element (using firebug in firefox).

Answer by egrunin

The font sizes are different because the browser programmers make different assumptions about the normal user’s system.

There’s nothing wrong with that, and this is also why you should not use px to set the font size. On a computer with a high-resolution screen, your font will be too small. Certainly 10px will be unreadable on many people’s computers.

I recommend How to Size Text in CSS for a good overview of your choices.

Answer by Starx

Try setting the font size in PX like font-size:10px

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!