Re: line-height: <number>

On Thu, 3 Feb 2000, Erik van der Poel wrote:
>>> [ line-height: <number> ]
>>>
>>> (1) It says "multiplied by the element's font size". Would that be
>>> the computed or actual value of font-size?
>> The same as with 'em'. i.e., a line-height of '3.4' means '3.4em'.
>> The only difference between specifying 'em' and <number> for
>> 'line-height' is the rather important difference in how it is
>> inherited.
> 
> The spec says:
> 
>#   The 'em' unit is equal to the computed value of the
>#   'font-size' property of the element on which it is used.
> 
> The above can be found here:
> 
>   http://www.w3.org/TR/REC-CSS2/syndata.html#value-def-length
> 
> So, as far as I can tell, the *specified* value "3.4em" is inherited
> by a child element, and you then multiply 3.4 by the font-size of
> that child element, not the parent element where line-height was
> inherited from.

No, it is always the computed value for 'line-height' that is
inherited, except if line-height is specified as a unit-less <number>.

Section 6.2:
# Specified percentage values are not inherited; computed values are.


> I think that percentages should be treated the same way as numbers.

If they were, then there would be no difference between numbers and
percentages. (But then there is no difference between 'em's and
percentages, the way things stand now.)


> However, the spec has an example (which is informative, not
> normative) saying that percentages are inherited in such a way that
> they apply to the parent's font-size:
> 
>   http://www.w3.org/TR/REC-CSS2/syndata.html#value-def-percentage
> 
> I believe that example is wrong, and percentage should be treated
> just like number. It's silly to use the font-size of a parent
> element, when the font-size of the child could be quite different
> (e.g. larger).

Absolutely. That is why line-height should (almost) always be
specified using a <number>, not a <length> or <percentage>.

-- 
Ian Hickson                            ("`-''-/").___..--''"`-._   
http://www.bath.ac.uk/%7Epy8ieh/        `6_ 6  )   `-.  (     ).`-.__.`)
                                        (_Y_.)'  ._   )  `._ `. ``-..-' fL
Member, Mozilla Quality Assurance     _..`--'_..-_/  /--'_.' ,'
Browser Standards Compliance Team    (il).-''  (li).'  ((!.-'    

Received on Thursday, 3 February 2000 20:43:25 UTC