Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many pixels is 1em in IE8?

Isn't 1em supposed to be 16px across all browsers?

I have this CSS

* {font-size: 1em; }
label { font-size: .85em; }

which on IE8 strangly gives label elements a height of 12px vs. the 13.6px I was hoping for.

Thanks for help!

like image 869
frequent Avatar asked Mar 03 '12 17:03

frequent


People also ask

How many pixels is 1em?

So, by default 1em = 16px, and 2em = 32px.

What is 1em font-size?

An em is a unit of measurement, relative to the size of the font; therefore, in a typeface set at a font-size of 16px, one em is 16px.

What is 1em equal to?

An em is equal to the current font-size, for instance, if the font-size of the document is 12pt, 1em is equal to 12pt. Ems are scalable in nature, so 2em would equal 24pt, .

What does 1em mean in CSS?

The em is simply the font size. In an element with a 2in font, 1em thus means 2in. Expressing sizes, such as margins and paddings, in em means they are related to the font size, and if the user has a big font (e.g., on a big screen) or a small font (e.g., on a handheld device), the sizes will be in proportion.


2 Answers

Isn't 1em supposed to be 16px across all browsers?

Not necessarily:

One 'Em'(1em) is equal to the height of the capital letter "M" in the default font size. When applied in CSS, the Em represents either the user's default font size, or the size of the parent element's font size, if one is available.

So while the default font size is 16px, perhaps you have a different size set on IE.

Also you may have some obscure parent element that is overriding it.

More info

like image 84
Kian Avatar answered Sep 30 '22 17:09

Kian


The unit em is relative.If you have a fontsize of 12pt, 1 em = 12pt. Using a fontsize of 20pt, 1 em = 20pt . It is derived from the letter M. It dates from the time and period when texts were created by a compositor. The letter M was the size of a square of the corpus .

like image 25
HERMAN KARSOWIDJOJO Avatar answered Sep 30 '22 16:09

HERMAN KARSOWIDJOJO