Is using a line-height
value of 1.4 the same as using a line-height
value of 140%? In other words, can we consider unitless value the same as perce
No.
The unitless values are calculated based on the element's font-size:
(unitless) The used value is this unitless multiplied by the element's own font size. The computed value is the same as the specified . In most cases, this is the preferred way to set line-height and avoid unexpected results due to inheritance.
Conversely, percentage-based values merely adjust the line-height
based on the calculated line-height
. Thus, if you have a calculated line-height
of 10px
, it will convert to 14px
if you use line-height: 140%
.