Text in html has a line-height
attribute that determines how much vertical space
the characters are given. By default, font size
and vertical space
do not match. If a span
has 50px font size
, line-height
of 50px
will produce a spacing at the bottom and top of the text.
http://jsfiddle.net/7vNpJ/773/
You can fix this by manually adjusting the line-height
, such as in this example:
http://jsfiddle.net/7vNpJ/774/
<span>
BIG TEXT
</span>
span {
display: inline-block;
font-size: 50px;
background-color: green;
line-height:0.7;
}
Line height of 0.7 only works for this particular font. I am looking for a way to perform this automatically, regardless of the font applied.
So basically I am looking for equation or procedure to set font-size and line-height so that there is zero spacing on top and bottom. What do you recommend that I do? A library that contains a matching line-height for many fonts would also do the trick.