>I doubt that. em is a unit relative to the current font size.
>http://en.wikipedia.org/wiki/Em_%28typography%29
><http://en.wikipedia.org/wiki/Em_%28typography%29> says: "Thus, em
>generally means the point size of the font in question." So if for one
>particular font size 1em is 16 pixels, for a font twice as big 1em might
>be rather about 32 pixels.
>
>Best
>
>Christian

Christian,
With all due respect you have it wrong in relation to CSS.
"Thus, em generally means the point size of the font in question." is correct
for print but not for CSS.

Here's what the W3C spec
<http://www.w3.org/TR/css3-values/#font-relative-lengths> has to say about it -


"Aside from ‘rem <http://www.w3.org/TR/css3-values/#rem-unit> ’ (which refers to
the font-size of the root element), the font-relative lengths refer to the
computed font metrics of the element on which they are used. The exception is
when they occur in the value of the ‘font-size’ property itself, in which case
they refer to the computed font metrics of the parent element (or the computed
font metrics corresponding to the initial values of the ‘font’ property, if the
element has no parent).

em unit

Equal to the computed value of the ‘font-size’ property of the element on which
it is used.

The rule:

h1 { line-height: 1.2em }

means that the line height of h1 elements will be 20% greater than the font size
of h1 element. On the other hand:

h1 { font-size: 1.2em }

means that the font size of h1 elements will be 20% greater than the computed
font size inherited by h1 elements."



The EM unit is relative to 1) the declared font-size of the element 2) the
font-size of the parent.

This is exactly why I use the REM unit. It is only relative to the font-size of
the root element and is not subject to any other unit.

html {font-size: 16px;}

Then all REMs on the page will be 16px no matter what eles.

When using EM's you can run into problems when the font-size or an element's
parent has a direct and not so nice effect on a child element's font-size.


Eric Miner
e...@minerbits.com

______________________________________________________________________
css-discuss [css-d@lists.css-discuss.org]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to