lh
The line height of the element it is used on.
Safe to useBaseline: widely available
| Browser | Since |
|---|---|
| Chrome | 109+ |
| Chrome Android | 109+ |
| Edge | 109+ |
| Firefox | 120+ |
| Firefox Android | 120+ |
| Safari | 16.4+ |
| Safari iOS | 16.4+ |
Formula 1lh = used line-height of the element
How it works
1lh is the used line height of the element. With line-height: 1.5 on a 20px font that comes to 30px, so block-size: 3lh holds exactly three lines of that text and min-block-size: 4lh makes a note panel at least four lines tall. The unit lets you size things in lines instead of guessing at pixels.
margin-block: 1lh gives paragraph spacing of exactly one blank line, in whatever font and size the paragraph uses. If line-height is normal, 1lh is the height of one line in that font, which differs from font to font, so set a number when you need the same result everywhere.
Inside the line-height property an element cannot refer to its own value, so lh there reads the parent’s. A child with line-height: 2lh under a parent whose lines are 20px tall gets 40px. And lh is a length, not a promise about the rendered text: a tall inline box, such as an 80px inline-block, stretches its line, so three lines with one such box in them are taller than 3lh.
Try it
Measure the font-relative units
Pick a font and a size. The page measures 1em, 1ex, 1ch, 1cap and 1lh in that font, here, in your browser.
| Unit | Measured | Share of the font size |
|---|---|---|
1em | ||
1ex | ||
1ch | ||
1cap | ||
1lh |
The same as a table
| Unit | Measures |
|---|---|
1em | The font size of the element. |
1ex | How tall the letter x is in this font. |
1ch | The width of the digit zero in the font. |
1cap | The height of a capital letter in the font. |
1lh | The line height of the element. |
What changes it
- Moves with
- the reader's text size
- page zoom
- Stays put under
- the window size
- the font in use
- the query container
- phone toolbars
- the writing mode
Reach for it when
Gaps and heights counted in the element's own lines: margin-block: 1lh, min-block-size: 4lh.
Watch out
With line-height: normal, 1lh depends on the font's own metrics, and a line can grow taller than line-height when tall inline content sits in it, so 3lh is not always three rendered lines.
Before
p + p {
margin-block-start: 24px;
}After
p + p {
margin-block-start: 1lh;
}