W3C home > Mailing lists > Public > www-style@w3.org > March 1999

Re: Line height, images, vert. alignment, and so on

From: L. David Baron <dbaron@fas.harvard.edu>
Date: Mon, 29 Mar 1999 11:31:09 -0500 (EST)
Message-Id: <199903291631.LAA15544@login4.fas.harvard.edu>
To: emeyer@sr71.lit.cwru.edu, www-style@w3.org
On Mon, 29 Mar 1999 09:44:45 -0500, "Eric A. Meyer"
(emeyer@sr71.lit.cwru.edu) wrote:
> >The height of the *line* box is increased, but the height of the
> >*inline* boxes (other than the image) are not.  The distinction is very
> >important.  Inline boxes represent inline elements.  A line box
> >contains inline elements or parts of inline elements.
> 
>    I just find this very hard to swallow.  If an image is part of a line,
> and it's significantly taller than the text, then visually speaking, the
> line height is increased to make vertical room for the image.  In CSS

The property 'line-height' has very little to do with the height of the
line, in complex situations.  It is called line-height, because in the
simplest case (all text, one font), it actually is the height of the
line.

> terms, as you say, the line box is increased.  Given that, then why is the
> computed 'line-height' for that line not increased as well?  Why are the

There is no such thing as a 'line-height' for a line.  There is a
computed 'line-height' for each element, and the height of the line is
computed from those (and the vertical-align for those elements).  The
line does not correspond to an element.

> line's height, and the height of the line-box, so divorced from one
> another?  I don't see why this is a good thing to do.  This is now perhaps

The line's height is the height of the line-box.  The 'line-height'
property describes the *exact* height of every (non-replaced) inline
box [1].  The inline box model (except for vertical alignment and
inheritance, but bear with me for a minute) does not have much to do
with containment:  there is nothing really wrong with
<b>text<i>text</b>text</i> - the b and i elements have their
line-boxes, which sit there, and the height of the line is from the
highest top to the lowest bottom.

See [2] for what I think is the best algorithm for calculating the
height of lines.  (That description is grounded in the spec, except for
the two changes I note there, and *maybe* some other inferences I made,
without which the rules would make no sense.)

> more a theoretical question than a "justify it under the spec" exercise.

I feel quite strongly that the spec's way is the right way to do it,
now that I understand it (with a few inferences that were left out of
the spec but must be true, I think).  If you start increasing the size of
inline boxes, then vertical alignment gets thrown way out of whack since
the glyphs are no longer centered vertically within the inline box.

>    If it's felt that images should NOT increase the 'line-height' of a
> line, then it seems to me that they ought not to be incresing the line-box
> either, and therefore be overlapping text, just as radically increased
> font-sizes are supposed to do.  Which, now that I think about it, is also a
> little weird.

The line has no 'line-height', so there's no paradox.

> >>    Is it the case that making the line-box bigger also increases the
> >> 'line-height'?  Because if so, the test for percentage values on
> >
> >No.  The value(s) of line-height describe the height of the inline boxes;
> >the replaced element increases the height of the line box.
> 
>    Okay, I agree that there is a clear distinction written into the
> specification, and the line-box model in general.  I just think it's a
> little whacked that such a distinction exists.

I think this distinction is absolutely necessary.  *Elements* in the
document tree have properties, and thus their properties must describe
some box (the inline box) relating to the element.  Lines do not
correspond to inline elements in any way, so they must have separate
boxes (line boxes).

David

[1] http://www.w3.org/TR/REC-CSS2/visudet.html#propdef-line-height
[2] http://lists.w3.org/Archives/Public/www-style/1999Mar/0121.html

-----------------------------------------------------------------
L. David Baron    Freshman, Harvard    dbaron@fas.harvard.edu
Links, SatPix, CSS, etc.  < http://www.fas.harvard.edu/~dbaron/ >
WSP CSS AC                < http://www.webstandards.org/css/ >
Received on Monday, 29 March 1999 11:31:12 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:53:58 GMT