Forum Moderators: open
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<div style="width: 100px; height: 100px; background-color: red;">
<h1 style="font-size: 24px; padding: 0; margin: 0; border: 0;">TEST</h1>
</div>
</body>
</html>
Firefox is rendering the header one pixel lower than all other browsers I've tested, including Internet Explorer, Chrome and Opera. Firefox may be rendering it correctly, I really don't know, but it sure is outnumbered in this case. The red box looks the same everywhere, as does the look of the text. A single pixel may seem like too small a thing to lose one's head over, but, unfortunately, in the layout I'm working on, the difference is quite noticeable and getting on my nerves since I can't get it fixed.
Is anyone familiar with this?
body element, is it that? If you mean one pixel lower within the red box, I can't see it specifically, but have you tried setting the line-height for the h1 element?
h1 header is rendered one pixel lower within the red box (in Firefox 3.0.5). Sorry if I was vague. I had not tried the line-height attribute for the h1 element. Having set it to 17px just now, I can see that the problem has been fixed in Chrome, Opera and even IE7 (i.e. they now render it as Firefox does), but not in IE6. So thanks for that. I suppose I could create a conditional comment for IE6 to set the line-height differently so it renders the header the same. I'd rather not, of course, but I don't really see any other options.
There are many reasons why em is preferred, just Google css + em, you will find many sources. There are occasions to use em's for things like margins, but often px or % works better (% usually scales better but can be tricky on some layouts).
What is an em? [w3schools.com...]
[edited by: Wlauzon at 4:05 am (utc) on Jan. 2, 2009]