Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line height default value if font size is 100%

Tags:

I must override the body style of my page:

body{     font-size:14px;     line-height:20px; } 

override:

body{     font-size:100%;     line-height:?????; } 

What is the defualt value of line-height property if I specified font-size:100% ?

Is there a strict relation between this properties ?

like image 888
grigno Avatar asked Apr 23 '13 07:04

grigno


People also ask

What Should Be default line height?

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.

How do you calculate line height from font size?

For the optimal readability and accessibility, you should go with140 – 180% line height (this is the space around a line of text). This means if your font size is 16pt, your line height should be at least 16 x 1.4 = 22.4pt (140%), or 16 x1. 8= 28.8pt (180%) maximum value.

Should line height be same as font size?

While there is no perfect line height, a good rule of thumb is to set it at approximately 150% of the font size. While there is no perfect line height, a good rule of thumb is to set it at approximately 150% of the font size.

What is 150% line height?

line-height: 150% will take 150% of the element's computed font size to compute the line height, which is equivalent to multiply it by 1.5 .


2 Answers

The default line-height is normal, so use:

body {     font-size: 100%;     line-height: normal; } 

FYI, you can confirm this if you have Chrome by opening up a website, inspecting the <body> element and viewing the inherited computed styles.

like image 191
Daniel Imms Avatar answered Oct 11 '22 04:10

Daniel Imms


Set a unitless value of 1, which will multiply the calculated font-size (i.e. how big the font turns out to be) with 1, making for a high-enough line-height.

You can also use 1.5 for a little more spacing.

So to finish your code it would be

body{   font-size:100%;   line-height: 1.5; } 

See the part on at https://developer.mozilla.org/en-US/docs/CSS/line-height for more details. Using a unitless number is stated as the preferred way of setting line-height.

like image 44
Willem Mulder Avatar answered Oct 11 '22 04:10

Willem Mulder