W3C home > Mailing lists > Public > www-style@w3.org > October 2009

Re: Inconsistent treatment of "em" and "ex" unit when used to specify "font-size"

From: Thomas Phinney <tphinney@cal.berkeley.edu>
Date: Mon, 26 Oct 2009 10:23:50 -0700
Message-ID: <f49ae6ac0910261023n442aae13m13a58d04ecff4eb2@mail.gmail.com>
To: Philip TAYLOR <P.Taylor@rhul.ac.uk>
Cc: W3C Style List <www-style@w3.org>
I believe you are correct in your perception of a self-referential problem here.

In the absence of an explicit x-height value, a value of 0.5 em would
indeed be a reasonable default. (Note that this is not half the cap
height: that value itself might average ~ 0.7 em; an aveage x-height
might be about 0.7x the cap height.)

Cheers,

T

On Mon, Oct 26, 2009 at 9:59 AM, Philip TAYLOR <P.Taylor@rhul.ac.uk> wrote:
> Intrigued by the bug report from Ryan Foster [2], I read
> the CSS 3 spec. on units, and read -- to my surprise -- the
> following :
>
> em     the font size of the element (or,
>       to the parent element's font size
>       if set on the 'font-size' property)
>
> ex     the x-height of the element's font
>
> Is there any reason why "ex" does not also reference
> the parent element's font size if set on the 'font-size'
> property, as if "ex" units are used to specify font-size,
> there would appear to be a problem of self-reference
> (see example below).
>
> Philip TAYLOR
> --------
> Example :
>
> <HTML>
>    <HEAD>
>        <TITLE>Title</TITLE>
>    </HEAD>
>    <BODY>
>        <DIV>
>        <! -- No explicit font so far -->
>            <SPAN style="font-size: 0.5em">ABCDabcd</SPAN>
>            <SPAN style="font-size: 1.0ex">ABCDabcd</SPAN>
>        </DIV>
>    </BODY<
> </HTML>
>
> The style declaration for the second span is would
> appear to be self-referential, since "the font's x-height" [1]
> cannot be known until the font-size has been computed ...
>
> ** Phil.
> --------
> [1] The 'ex' unit is defined by the font's x-height.
>    The x-height is so called because it is often equal
>    to the height of the lowercase "x". However, an 'ex'
>    is defined even for fonts that don't contain an "x".
>    Should we say that ex is 0.5em if no better value exists?
> --------
> [2] Ryan Foster wrote:
>
>> When set to CSS3, the CSS Validator states:
>>
>>     Value Error : min-width
>>
>> <http://jigsaw.w3.org/css-validator/nullvisudet.html#propdef-min-width>
>>     Unknown dimension 15ch
>>
>> While the CSS3 Values and Units <http://www.w3.org/TR/css3-values/> draft
>> specification states <http://www.w3.org/TR/css3-values/#relative0>:
>>
>>     ch:  The width of the "0" (ZERO, U+0030) glyph found in the font for
>>     the font size used to render. If the "0" glyph is not found in the
>>     font, the average character width may be used. How is the "average
>>     character width" found?
>>
>> The Validator should mark "ch" as a valid unit when set to CSS3.  The same
>> error occurs in the development version
>> (http://qa-dev.w3.org:8001/css-validator/).
>
>
Received on Monday, 26 October 2009 17:24:23 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:21 GMT