Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery/CSS: line-height of "normal" == ?px

Tags:

jquery

css

I'm calling $("#foobar").css("line-height") and getting back "normal". How do I translate this to a pixel amount? Is "normal" defined in the CSS spec or is it browser specific?

like image 419
JamesBrownIsDead Avatar asked Sep 01 '10 00:09

JamesBrownIsDead


People also ask

What is line height normal in PX?

If your font size is 10px, your line height will be 10px, 18px, and 20px, respectively. Sets line height as a percentage of the font size of the element. If your font size is 10px, your line height will be 3px, 5px, and 11px respectively. Alternatively, you can specify the “normal” keyword.

What is the normal line height in CSS?

Depends on the user agent. Desktop browsers (including Firefox) use a default value of roughly 1.2 , depending on the element's font-family . The used value is this unitless <number> multiplied by the element's own font size.

What size is line height normal?

According to this page, it seems most of recent browsers use the same value for line-height: normal : 1.14, id est the font-size property with a 1.14 coefficient.

How do I fix the height of a line in HTML?

It turns out that's pretty simple: just use the line-height CSS property and then apply it. I have an example below. Then, you can apply that CSS class to your HTML. Now, the space between the lines changes.


2 Answers

According to this page, it seems most of recent browsers use the same value for line-height: normal : 1.14, id est the font-size property with a 1.14 coefficient.

Tried with several browsers (on Windows XP) :

  • Chrome 21.0.1180.75
  • Firefox 14.0.1
  • Safari 5.1.7
  • Opera 11.64
  • IE 7
  • IE 8

EDIT

I was wrong, line-height depends of font-family, font-size, your browser, maybe your OS...

More reading on Eric Meyers' website.

like image 151
zessx Avatar answered Oct 06 '22 13:10

zessx


Normal is actually referred to as abnormal on several instances as there is quite a browser inconsistency.

declaring line-height: normal not only vary from browser to browser, which I had expected—in fact, quantifying those differences was the whole point—but they also vary from one font face to another, and can also vary within a given face.

like image 30
Frankie Avatar answered Oct 06 '22 15:10

Frankie