So I have a div with a span inside. And I'm setting display:block or display:flex on the div, and a small font-size on the span. Surprisingly, this is giving different heights on the div. See the example.
If I set the smaller font-size on the body or div then the height of both is equal. But if I set the smaller font-size on the span like in the example, then the divs get different heights. How come? And can I do anything about it?
span {
font-size: 0.8rem;
border: 1px red solid;
}
div {
border: 1px blue solid;
}
<div style="display: block;">
<span>test text 1</span>
</div>
<div style="display: flex;">
<span>test text 2</span>
</div>