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

Re: em and ex in font-size

From: Matthew Brealey <thelawnet@yahoo.com>
Date: Wed, 26 Jan 2000 04:14:18 -0800 (PST)
Message-ID: <20000126121418.23033.qmail@web905.mail.yahoo.com>
To: www-style <www-style@w3.org>
--- JOrendorff@ixl.com wrote:
> 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.
<blockquote
cite="http://www.w3.org/TR/REC-CSS2/fonts.html#font-properties".
On all properties except 'font-size', 'em' and 'ex' length values refer to
the font size of the current element. For 'font-size', these length units
refer to the font size of the parent element.
</blockquote>
Anyway, exes are useless on font-size (and indeed virtually every other
property) unless you know the x-height of the parent - you can't use
x-height to define an em square height. 

=====
----------------------------------------------------------
From Matthew Brealey (http://members.tripod.co.uk/lawnet (for law)or http://members.tripod.co.uk/lawnet/WEBFRAME.HTM (for CSS))
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com
Received on Wednesday, 26 January 2000 07:14:19 GMT

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