Line height unit
Alignment
Computed line box: 24 px
font-size: 16px; line-height: 1.5; text-align: left;
Help Us Improve
—
(—)
CSS line height calculator
Set font size and line height, preview the text block, and copy CSS. Unitless, px, or percent — free, no sign-in.
What is a line height calculator?
Line height controls
Font size: Set the type size in pixels from 10 to 72.
Unitless, px, or percent: Switch the line-height unit and see the computed line box.
Alignment: Preview left, center, or justified text with the same leading.
Copy CSS: Copy font-size, line-height, and text-align together.
How to set line height
Set the font size
Match the size you plan to use in CSS.
Pick a unit
Unitless scales with the font. Pixels and percent are fixed to the number you set.
Read the line box
The pixel value is the used height of one line.
Copy the CSS
Paste font-size, line-height, and text-align into your stylesheet.
Tips for line height
- 01
Prefer unitless for body text
A multiplier stays proportional when the font size changes.
- 02
Tighten display type
Large headings often look better below 1.2 than at a body setting of 1.5.
- 03
Check justification with real words
Replace the sample with your paragraph before you trust the rag and the gaps.
When to check line height
Body copy
Open a paragraph until the lines separate without looking sparse.
Spec matching
Convert a unitless leading into pixels for a fixed layout.
Justified paragraphs
See how justification sits at the same line height as left-aligned text.
Why calculate line height here
No sign-in
Adjust the sliders and copy CSS. No account.
Free
The preview and the copied CSS have no watermark.
Shows the used pixel size
Unitless and percent values are converted to the line box in pixels.
Technical details
- Unitless
- Line box = font size × line height. 16px × 1.5 = 24px.
- Pixels
- The line box is the pixel value you set, independent of font size.
- Percent
- Line box = font size × (percent / 100). 150% of 16px is 24px.
- Preview
- The sample uses the CSS font-size, line-height, and text-align you set. The browser’s default font is used.
Sources & References
“The line-height CSS property sets the height of a line box in horizontal writing modes. It is commonly used to set the distance between lines of text.”
line-height: This calculator previews that property as a unitless number, a length in pixels, or a percentage of the font size. developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/line-height
“Line height (line spacing) to at least 1.5 times the font size.”
Text spacing: The 1.5 starting point in the preview matches this text-spacing floor for body copy. Headings can be tighter. w3.org/WAI/WCAG22/Understanding/text-spacing.html