As is specified in W3's section on inline formatting contexts the user agents flow inline boxes into a vertical stack of line boxes.
Moreover, W3 also states that the height of line boxes is determined by the rules given in the section on line height calculations
When I created a simple inline <span>
on my test site, I spotted a little bit of space above and below the text. I am trying to figure out where that comes from, and trim it away by adjusting the line-height property.
I simply tried:
<span style="line-height:8pt; border:solid red 1px;">Test</span>
I also tried:
<div style="white-space: pre-line; line-height: 5pt">
<span style="line-height:5pt; border:solid red 1px; ">Test</span>
<span style="line-height:5pt; border:solid blue 1px">Test</span>
</div>
The border is there to demonstrate the outer edges of the line box. The pt numbers are arbitrary. I normally use a unitless number, as recommended in the W3 specs.
The question is: Why is there a little bit of space above and below the characters, regardless of what the line-height is set to? How can this be removed?
Image (see the top red "Test" box):
Thank you.