开发者

Why are the font sizes different

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).


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.


pt is a unit used for print and is not reliable for cross browser screen sizing. Try using another unit like px, em or a straight percentage.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜