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

em and ex in font-size

From: <JOrendorff@ixl.com>
Date: Tue, 25 Jan 2000 21:38:37 -0500
Message-ID: <CD8E2CDBC6D0D111ACB900805FBBD97E02630147@mem-131.ixl.com>
To: www-style@w3.org
The intention of the CSS below is to make CODE content look the
same size as the surrounding text.  That is, the CODE font should
have the same x-height as its parent's font.

    CODE {
      font-family: "Courier New", monospace;
      font-size: 2.34ex;
      font-size-adjust: 0.427;
    }

It doesn't work as expected because of a subtle difference
between 'ex' and 'em'.

'em' is specially defined to refer to the parent element's font when
used in 'font-size'.[1]  'ex' doesn't get the same special treatment.
So 'font-size: 2.34ex;' really makes no sense-- it is redundantly
defining the font to be 2.34 times as tall as its own x-height,
which would be true regardless of the font-size.

Is this an oversight?  Could it be changed for CSS3?

[1]http://www.w3.org/TR/REC-CSS2/syndata.html#length-units
("The exception is when 'em' occurs in the value of the 'font-size'
property itself...")

-- 
Jason Orendorff
Received on Tuesday, 25 January 2000 21:43:44 GMT

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