Does font size affect block element height?

Does block element height depend on content font size?

It’s best to just show you what I mean, look at this fiddle example

If you increase the font size of the class .pinside the div, the height of the div also increases, why is this?

+5
source share
5 answers

This is because the font size of the div determines where the base line for the text is located, and the range is placed on that base line.

div . , , , , , , , .

+7

, height -property . height: auto.

+1

div.

, div , , p.

, height:auto.

+1
0

Because the line height is estimated according to the font size. To stop div expansion in response to font size, the line-height property in CSS is explicitly set.

0
source

All Articles