Quick Answer
For a 16px font with a line-height of 1.5, the computed height is 24px. The leading (spacing above and below the text) is 8px total, split equally as 4px above and 4px below each line.
Typography Settings
Common Examples
| Input | Result |
|---|---|
| 16px font, 24px line height | Ratio 1.5, 1.5em, 8px spacing |
| 16px font, ratio 1.5 | 24px, 1.5em |
| 20px font, 1.6em line height | 32px, ratio 1.6 |
| 14px font, 22px line height | Ratio 1.5714, 1.5714em |
| 18px font, ratio 1.4 | 25.2px, 1.4em, 7.2px spacing |
How It Works
The CSS line-height property sets the height of a line box, which determines the vertical distance between baselines of adjacent lines. It can be specified in several ways:
Unitless number (recommended): line-height: 1.5 means 1.5 times the font size
Pixel value: line-height: 24px sets an absolute line height
Em value: line-height: 1.5em is equivalent to a unitless 1.5 for that element, but behaves differently when inherited
Conversion formulas
- To px: Line Height (px) = Font Size (px) x Ratio
- To ratio: Ratio = Line Height (px) / Font Size (px)
- Leading (spacing): Leading = Line Height (px) - Font Size (px)
The leading is split equally above and below the text. For a 16px font at line-height 1.5 (24px), the 8px of leading places 4px above and 4px below each line of text.
Why unitless line-height is recommended
A unitless value like line-height: 1.5 is inherited as a ratio, meaning child elements recalculate the line height based on their own font size. A value like line-height: 1.5em or line-height: 24px is inherited as a computed value, so child elements with a different font size may have incorrect spacing.
For example, with a parent at font-size: 16px; line-height: 1.5em (computed 24px), a child at font-size: 32px inherits the computed 24px, creating overlapping text. With line-height: 1.5 (unitless), the child computes 32 x 1.5 = 48px.
Recommended line-height values
- Body text: 1.4 to 1.6 (higher for longer lines, lower for shorter)
- Headings: 1.1 to 1.3
- Buttons and labels: 1.0 to 1.2
- Small text: 1.5 to 1.8 (more spacing improves readability)
Worked Example
For a 20px font with a line-height of 32px: Ratio = 32 / 20 = 1.6. Em = 1.6em. Leading = 32 - 20 = 12px (6px above, 6px below each line). CSS: font-size: 20px; line-height: 1.6;
Related Calculators
Frequently Asked Questions
What is a good line-height for body text?
What is the difference between unitless and em line-height?
1.5 is inherited as a multiplier. Each child element recalculates line height based on its own font size. An em-based line-height like 1.5em is computed to a pixel value and that fixed value is inherited. Unitless values are recommended because they adapt correctly to different font sizes in child elements.
CalculateY