Forum Moderators: not2easy

Message Too Old, No Replies

css line spacing

show different in mozilla an ie

         

madmatt69

3:46 am on Aug 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi everyone,

Using the css shorthand for line spacing, in my font class. ex: font:bold 12px/10px arial;

The line spacing displays correct in mozilla, but looks way to big in IE - For me to get it to look the way it does in mozilla, i have to set it to 12px/2px - And of course in mozilla that is way to small, but IE renders it as if it was 12/10 or so.

Any idea why? I've never had this issue before.

Once again, any help is much appreciated!

createErrorMsg

1:26 am on Aug 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I had to guess, I would say IE is choking on the W3 specs here. (Which version of IE, anyway?)

The size part of the shorthand font property goes...

font-size/line-height

...Note it is line-height not line spacing. When you set these values to 12px/10px, you're actually telling the browser to use a 12px font and a minimum 10px line-height. Mozilla presumably sees that the font is bigger than the line-height and simply makes the line-height large enough to hold the font, plus any margins and padding involved.

IE may not be handling this correctly, though, and it sounds like it might not be recognizing the 'length' value you've given for line-height (in PX) and is instead interpretting it as a 'number' value (which is a multiplier of the font-size, see [w3.org...] for details). If so, IE would be giving you a line-height somewhere around 10 times the height of the font...way to big. That '2px' does the trick -- which if interpretted as a 'number' value would be twice the size of the font, split between top and bottom -- reinforces this conclusion.

My suggestion? Don't define the line-height with a 'length' (i.e., PX) value but instead use a 'number' value (1.5 for one and a half times the font size) in the CSS. Both browsers ought to interpret this the same.

madmatt69

6:51 pm on Aug 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Tried it, but still not working - I'm using IE6 and Mozilla FireFox.

The line height changes but they still don't display uniform. Any other ideas?

createErrorMsg

7:28 pm on Aug 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is the element whose line-height is being messed up? A <p>aragraph? <h>eader? <l>ist item?

madmatt69

1:35 am on Aug 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<P> paragraph

createErrorMsg

2:27 pm on Aug 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IE may be adding a default top and/or bottom margin to the <p> element (it does this with a lot of elements). If you haven't already, try explicitly setting it to 0 and see if that helps...

p {
margin:0;
}