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

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

From: Philip TAYLOR <P.Taylor@Rhul.Ac.Uk>
Date: Mon, 26 Oct 2009 16:59:59 +0000
Message-ID: <4AE5D58F.4010704@Rhul.Ac.Uk>
To: W3C Style List <www-style@w3.org>
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:00:44 GMT

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