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:
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;
}
Try to set the
body{font-size:medium; line-height:1em;}
where the font-size will be of16px
now and use percent onp
tag to increase or decrease thefont-size
. To be sure of limit the width of thep
tag.Two possible things, both untested:
try changing the doctype to something other than xhtml transitional. See if the HTML5 doctype renders it better.
<!DOCTYPE html>
try using only
font-family: monospace;
to see if it is a font issue.EDIT
If those do not work and you cannot find a solution, you might want to serve IE9 a different
font-size
using conditional comments.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: http://blog.mozilla.com/nattokirai/2011/08/11/directwrite-text-rendering-in-firefox-6/