Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is IE9/Firefox showing a different font size in relation to other browsers?

I'm programming the CSS of a site, and realized that the Internet Explorer 9 is showing different font size in relation to other browsers (Firefox, Chrome, Safari, IE7 and IE8).

I've tried using some RESETS, and I am specifying the font in px, but IE9 still shows the difference in font size.

I've tried using font-size in pt, in, percentage, but had no success.

I changed the font before (Georgia, Times New Roman, Verdana). Some of them are shown larger, others are smaller in IE9.

I checked the zoom settings and text size in IE. They are 100% and medium respectively.

To illustrate, I created a simple HTML and CSS as you can see the code below. How to solve this problem? Thanks!

The problem:

enter image description here

Code:

HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="style.css" />
    <title>Untitled Document</title>
</head>
<body>
    <p>
    AAAAA BBBBB CCCCC DDDDD EEEEE FFFFF GGGGG HHHHH IIIII JJJJJ KKKKK LLLLL MMMMM NNNNNN OOOOO PPPPP QQQQQ
    </p>
</body>
</html>

CSS

/* RESET */

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}

/* END OF RESET */

body {
    background-image:url(GreenLine.png);
    background-repeat:no-repeat;
    font-family:"Courier New", Courier, monospace;
    font-size:12px;
}
like image 942
bbastos Avatar asked Sep 21 '11 12:09

bbastos


1 Answers

IE9 uses DirectWrite to render text, and other browsers do not (except for Firefox 4+).

That is the reason for the slightly different size of the text between the two browsers.

There is no way to make the text the same size.

Read this: http://www.basschouten.com/blog1.php/font-rendering-gdi-versus-directwrite

And this, particularly the "Hinting and spacing differences" section: https://web.archive.org/web/20120603023828/https://blog.mozilla.org/nattokirai/2011/08/11/directwrite-text-rendering-in-firefox-6/

like image 199
thirtydot Avatar answered Oct 04 '22 02:10

thirtydot