I am still not clear what does size in em mean?
I have worked px, pt in CSS.
What would 0.8, 1.0 and 1.2 em mean?
I have seen height's in CSS like:
height: 0.8em; or height: 1.2em;
How is it calculated?
views:
62answers:
6An em is the width of the letter "m" (in your current font and size).
1em is equal to the current font size. 2em means 2 times the size of the current font. E.g., if an element is displayed with a font of 12 pt, then '2em' is 24 pt. The 'em' is a very useful unit in CSS, since it can adapt automatically to the font that the reader uses.
Paul is correct, however its "M" not "m". However this is an esoteric definition derived from typesetting/printing and isnt of much use in this case. In terms of whats going to be useful to you you its a percentage of font size.
Em is the size of a character. It will vary depending upon the font size. If the font size is 24 then 2Em will be equal to the space it should take to hold two characters of the font size 24.
As quoted from wiki.
An em is a unit of measurement in the field of typography. This unit defines the proportion of the letter width and height with respect to the point size of the current font.
FYI: En is half of Em. 0.5Em
The meaning of "em" has changed over the years. Not all fonts have the letter "M" in them (for example, Chinese), but all fonts have a height. The term has therefore come to mean the height of the font – not the width of the letter "M."
A very clear and informative example:
Let's look at a simple example where we use the em unit to set font sizes:
<HTML>
<STYLE>
H1 { font-size: 2em }
</STYLE>
<BODY>
<H1>Movies</H1>
</BODY>
</HTML>
When used to specify font sizes, the em unit refers to the font size of the parent element. So, in the previous example, the font size of the H1 element is set to be twice the font size of the BODY element. To find what the font size of the H1 element will be, we need to know the font size of BODY. Because this isn't specified in the style sheet, the browser must find it from somewhere else – a good place to look is in the user's preferences. So, if the user sets the normal font size to 10 points, the size of the H1 element is 20 points. This makes document headlines stand out relative to the surrounding text. Therefore: Always use ems to set font sizes!