This is your original code:
<div style="line-height: 150%;">
<span style="display: block; font-size: 240%;">Test</span>
</div>
This sets the line-height
of all the elements inside the div
to 150%. This percentage is relative to their computed font size.
The span
inherits the font-size
of the div
, and the line-height
is calculated based on that.
You set the font-size
of the span
to 24 times its inherited size, but the line-height
is unaffected.
In short: line-height: 150%
will take 150% of the element’s computed font size to compute the line height, which is equivalent to multiply it by 1.5.
As mentioned, using line-height: 1.5;
instead fixes that behavior:
<div style="line-height: 1.5;">
<span style="display: block; font-size: 240%;">Test</span>
</div>
This triggers the recalculation of the line-height
based on the new font size.
It sets the line-height
of all the elements inside the div
to 1.5 times. This percentage is relative to their actual font size.
The span
inherits the font-size
of the div
.
You set the font-size
of the span
to 2.4 times its inherited size, and the new line-height
is calculated based on that.
In short: line-height: 1.5
(without units) will multiply the element’s actual font size by 1.5
to compute the line height.