CSS Reference ยท Typography
The line-height property
Reference for the CSS line-height property: unitless numbers vs lengths, how it inherits, good values for body text and headings, with live examples.
The line-height property sets the minimum height of each line box in a block of text. A larger value adds space between lines, a smaller value packs them closer. It is one of the biggest levers for readability: body text usually feels comfortable somewhere around 1.4 to 1.7 times the font size.
The recommended way to write it is as a plain number with no unit. A unitless number is multiplied by the font size of each element that inherits it, so every descendant gets proportional spacing.
body { line-height: 1.6; } h1 { line-height: 1.2; }
Try it
Syntax
line-height: normal | <number> | <length> | <percentage>;
- Initial value:
normal - Applies to: all elements; also
::first-letter,::first-lineand::placeholder - Inherited: yes
- Animatable: yes, for numbers, lengths and percentages
- Computed value:
normalor the number as specified; lengths and percentages become absolute lengths
Values
| Value | Description |
|---|---|
normal |
The browser chooses a value based on the font's metrics, typically around 1.2. |
<number> |
The font size multiplied by the number. Inherited as the number, so each descendant recalculates. |
<length> |
A fixed height, such as 24px or 1.5rem. Em values are resolved against the element's own font size, then inherited as that fixed length. |
<percentage> |
Relative to the element's own font size, then inherited as the computed length (like an em value). |
Usage notes
- Prefer unitless numbers. Lengths and percentages are resolved once and inherited as fixed lengths, which causes cramped text in children with a larger font size.
- Set it on
body, override sparingly. A single base value (1.5 to 1.7 for paragraphs) plus tighter values for large headings (about 1.1 to 1.3) covers most designs. - Large text needs less. Because the value is a multiple of the font size, 1.6 on a 48px heading looks far too loose. Reduce it for headings.
- Accessibility. Users with reading difficulties benefit from line spacing of at least 1.5 for body text. Avoid fixed pixel heights on text containers, so text can grow without overlapping.
- Single-line controls. Setting the same
line-heightandheightis an old trick for vertical centering of one line. Flexbox or grid withalign-itemsis more robust. - Replaced inline content. Tall inline images or
vertical-alignshifts can make a line taller thanline-heightsuggests, because it is a minimum. - Not the same as spacing between paragraphs. Use
marginfor that.
Browser support
Supported in every browser.
Related
font-sizeโ the size the number multipliesletter-spacingandword-spacingโ horizontal spacingvertical-alignโ shifts inline boxes within a line- Lesson: Line Height and Vertical Rhythm
- Lesson: Styling Text