Is there a way to make text in CSS actually match the height I give it?
What I mean is, if you set a font to 14px, it's not actually 14px tall if you measure it. It's more like 10px.
Here is a JSFiddle to illustrate what I'm talking about: https://jsfiddle.net/bbtk986d/2/
Notice how the text doesn't actually touch the edges of the green areas. It's a few pixels off, even though it should be exactly right.
The problem is when trying to follow a style guide (like Google Materials), they say something like 14px, but 14px is actually too small because they mean exactly 14px. I'd love to be able to change how it renders to get it exact so I don't have to tweak every last value.
Fiddle code:
HTML:
<div>
<span></span>
<span></span>
<span></span>
<p>
Text
</p>
</div>
<div>
<span></span>
<span></span>
<span></span>
<p class="b">
Text
</p>
</div>
<div>
<span></span>
<span></span>
<span></span>
<p class="c">
Text
</p>
</div>
<div>
<span></span>
<span></span>
<span></span>
<p class="d">
Text
</p>
</div>
CSS:
div {
position: relative;
width: 300px;
margin-bottom: 10px;
}
span {
width: 100%;
background: #FCC;
height: 20px;
display: block;
}
span:nth-child(2) {
background: #CFC;
height: 40px;
}
p {
position: absolute;
top: -40px;
left: 50%;
transform: translateX(-50%);
opacity: .5;
text-transform: uppercase;
display: block;
padding: 0 10px;
font-size: 40px;
line-height: 80px;
}
p.b {
font-family: Arial;
}
p.c {
font-family: "Comic Sans MS"
}
p.d {
font-family: monospace;
}