RE: line-height: <length> should be revoked

On Sun, 11 Apr 2004, Ernest Cline wrote:

> > From: Felix Miata <mrmazda@ij.net>
- -
> > 	body {font-size: 100%; line-height: 1.2em;} and nothing for H1.
> >
> > The H1 there overlaps in Mozilla, Opera, and Safari
> > http://members.ij.net/mrmazda/ss/konq-org.png (19.2px line-height for
> > 32px text), but not in IE6 or Konqueror 3.1.1.
>
> This would be because Mozilla, Opera, and Safari are following
>  the W3C spec.

I don't know where the problem comes from, but on IE 6, a simple text with
the CSS rule quoted makes an h1 element's line-height 1.2 times the body
element's font size, as defined. So I guess there's something else that
affects the rendering on that page.

> > IOW, for this particular case, the line-height:
> > 1.2em in body applied to H1 should be applied to the font-size of the H1
- -
> Actually, I can imagine wanting to have the parent element setting
> the line height

I don't think that's the most essential point. Setting line-height
for body sets it for all elements inside body, too, unless there are other
line-height settings in effect. But setting line-height: 1.2em,
line-height: 120%, and line-height: 1.2 have different effects on
subelements, despite the fact that for the body element itself they are
equivalent.

The key problem seems to be the interpretation of the em unit, which is
constant cause of surprises to authors, when an element's font size does
not equal its parent's font size. Maybe this _is_ too confusing, but it's
too late to change it. When setting margins in em units for heading
elements, it's easy to forget that em means the size of the font in the
heading element, not the font size of the enclosing element (typically,
the basic font size of the page). There might be use for a unit that
corresponds to the parent element's font size.

> Looking at MSDN, I see that according to Microsoft's documentation
> 'line-height' does not inherit, while according to W3C, it does.
> Clearly, MS has chosen to not have 'line-height' inherit.

But IE actually treats line-height as inherited, so apparently the
documentation is in error. At least in simple tests, IE seems to apply
correct inheritance rules. If I set line-height: 1.2em, the computed value
is inherited; if I set line-height: 1.2, the number is inherited.

It's easy to get confused with these things (even CSS drafts and "Errata"
have recommended using the em unit for body in a browser's default style
sheet, which is fairly unreasonable) but I don't think it would help much
to simplify the specification in this respect. There are situations where
'length' makes perfect sense as line-height value, e.g. in a user style
sheet that sets it in points.

-- 
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/

Received on Sunday, 11 April 2004 18:02:32 UTC