Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bold text line-height is higher than normal text line-height

Tags:

html

css

Must be something basic I'm missing here. I thought that font-weight:bold should not change how much vertical space the text takes. Especially when the line-height is set to be higher than the font-size.

http://jsfiddle.net/Arkkimaagi/7xAyy/

On my OSX chrome those three text heights do not match. The second one with font-weight:bold is 1px higher than the rest. The third div is just an example of fixing the problem (poorly)

I'm trying to set the line-height to something specific (18px) here, to have "vertical rhythm"

My question is, how can I have bold and normal text both with same line-height as in the example?

[edit:] here's what I see on my mac Example of the problem on my osx

Also, here is what I ment by "vertical rhythm": http://www.alistapart.com/articles/settingtypeontheweb - the baseline grid is more visible in the example: http://www.alistapart.com/d/settingtypeontheweb/example_grid.html

like image 300
Mikko Tapionlinna Avatar asked Dec 04 '11 16:12

Mikko Tapionlinna


People also ask

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.

Can line height be less than font size?

If the value of the line-height property is smaller than the value of the font-size , text may overflow the element, and text on one line may overlap text on another line above or below it. It is often convenient to set the value of the line-height in the font shorthand property.

What is line height of text?

Line height is the vertical distance between two lines of type, measured from the baseline of one line of type to the baseline of the next. Traditionally, in metal type, this was the combined measurement of the font size and the strips of lead that were inserted between each row (called “leading”) of type.

How do you scale the height of a line?

The perfect line height depends on the design and size of the font itself. There is no magic number that works for all text. A line height of 1.5 times the font size is a good place to start from, and then you can adjust accordingly. Using an 8 point grid system works well when using 1.5 line height.


2 Answers

Sometimes adding top vertical align will solve this (depending on font size/family).

strong { vertical-align: top; }

In your fiddle example, because you have set a line height on the container (div), you can simply add the following:

span { line-height: 1em; }
like image 82
DaveC Avatar answered Sep 19 '22 18:09

DaveC


It completely depends on the fonts you are using. Nothing about OSX or Chrome text rendering would ensure that two different fonts (and Helvetica-neue and Helvetica-neue-bold are two different fonts) would have the same vertical space even at the same font-size and line height.

Even though that is too much to ask you might think that two different fonts from the same family might be consistent, and usually they are, but sadly the two fonts you have chosen are not.

like image 21
hooleyhoop Avatar answered Sep 18 '22 18:09

hooleyhoop