Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font-size increases the top margin

Tags:

html

css

Why is it that if I do font-size:70px or 120px, the distance between the top and the text increases?

EDIT : Apparently, I fixed it by changing the line-height. Is there a default line-height?

like image 781
user461316 Avatar asked Mar 13 '26 16:03

user461316


1 Answers

As you haven't shown any code I will make the assumption that you're not using any styles beyond:

body
{
  font-size: 70px;
}

Every browser has a different default stylesheet, so the actual values may vary.

Typically the default line-height is 1em or 100% (same thing). On certain elements such as p and h#, there is a top and bottom margin by default. For p tags, the margin is 1em and for h# it varies widely (1.5em for h1, 1.25em for h2 etc).

em and % values are based off of the font-size. If you have a paragraph element with a font-size of 30px, by default it will have a 30px top and bottom margin.

like image 77
zzzzBov Avatar answered Mar 15 '26 05:03

zzzzBov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!