When setting CSS font-size in pixels, does the value refer to the width or height of a letter?

前端 未结 3 363
终归单人心
终归单人心 2020-12-15 17:10

Does the pixel value of a font-size refer to the height of the font or the width of the font?

CSS:

.sixteen {
  font-size: 16px;
}

3条回答
  •  春和景丽
    2020-12-15 17:25

    According to this article by Vincent De Oliveira, the font-size actually has nothing to do with the actual height of characters. It's not even the height of the inline element that contains text.

    Of course, a larger value of the font-size property results in a larger text. But the pixel value does not directly translate into the actual size of text.

    However, the pixel value of font-size sets the size of 1em to be used for setting margin, padding, etc.

提交回复
热议问题