W3C home > Mailing lists > Public > www-style@w3.org > January 2008

Re: Line layout in browsers

From: Ben Cotterell <ben.cotterell@antplc.com>
Date: Tue, 22 Jan 2008 10:56:57 +0000
To: www-style@w3.org
Message-ID: <d4ae7145c53694f0936eb45b99f6857e5b4f61c0@localhost>

On Tue, Jan 22, 2008 at 10:10:54AM +0200, Jukka K. Korpela wrote:
> 
> Alex Mogilevsky wrote:
> 
> > "normal" line height is what font designer decided would be the
> > perfect distance between two lines; when represented in EMs it is
> > nearly always bigger than one.
> 
> You mean "between baselines of text", right?
> 
> But in CSS, "normal" is a browser-dependent constant, interpreted with 
> em as the implied unit (though inherited as a number, not as computed 
> value). I haven't seen anything in CSS specifications and drafts that 
> suggests anything else, and they have rather different views on what 
> this constant might or should be.
> 
> So it has to be decided on a "one size fits all" basis.

Why? At least some fonts have some sort of suggested "line gap" stored
in them.

The browser could do worse than base line-height: normal on that (I
would have assumed that's what they did do).

If it did, or in some other way chose font-specific values generally
between 1.0 and 1.2, which part of CSS 2.1 would it be violating?

Or are you saying just that authors have come to expect line-height:
normal to be a constant for all fonts?

[...]

> This means that to add a more logical way, a new unit is needed. It 
> would equal the default line-height for the font of the element; such a 
> default would have to be postulated for all fonts, with the idea that it 
> is normally taken from the font designer's suggestion. Then people could 
> use this unit to specify the line-height as a multiple of it - as people 
> currently do (typically without knowing this and without knowing the 
> default line-height), when they set line height in Microsoft Word, for 
> example.
> 
> This would not break existing style sheets, and authors could also 
> provide a backup rule for browsers than don't recognize the new unit, 
> e.g.
> 
> * { line-height: 1.3; } /* for old browsers */
> * { line-height: 1.1dlh; } /* for new browsers, 1.1 times default line 
> height */

That would be reasonable. Then people could do in CSS what's sometimes
called "double spacing"-- i.e. 2dlh.

-- 
Ben Cotterell
Senior Software Engineer, ANT Software Limited
Received on Wednesday, 23 January 2008 04:16:30 GMT

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