Line boxes are associated with the containing block element, such as the .test
element in this case. Inline elements like the span are segmented into multiple inline boxes that fit within the line boxes separated by line breaks.
Each line within the .test
element consists of a zero-width inline box known as a strut
along with a portion of the span. While the span has a line-height of 15px, the strut's line-height is determined by the .test
element.
If there are no changes to font family, font sizes, or vertical alignments, the space between two lines is equal to the higher value between the line height of the strut and the line height of the span.
By default, with standard font size, font-family, and line-height settings, the strut's line height can range from 18 to 19 pixels, which explains why there may be larger gaps than anticipated.
To decrease the spacing between lines, adjust both the strut's line-height and the span's line-height by setting the line-height for the containing block. The span element can inherit this adjustment. For example:
body { width:200px; } /* demo purposes for displaying multiple lines */
.test {
line-height: 15px;
}
<div class="test">
<span>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
</span>
</div>