em and ex in font-size

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 UTC