Skip to the workspace
Pebellslearn by building
Fonts and Text Styling  ›  Capstone Project

Line Height and Text Spacing

Line Height 15 minA unitless line-height is inherited as a factor that scales with each element's font size, while letter-spacing, word-spacing and text-transform fine-tune how a line reads.

css / Line Height and Text Spacing

Explore each scene at your own pace.

01 · The rule

The rule

Line Height and Text Spacing

A unitless line-height is inherited as a factor that scales with each element's font size, while letter-spacing, word-spacing and text-transform fine-tune how a line reads.

Compare line-height and spacing choices across nested text with different font sizes.

The café's menu uses a beautiful font at the right size, yet descriptions still feel cramped and hard to read. The usual culprit is not the font at all. It is the space between the lines and between the letters.

The rule

Give lines room with a unitless line-height; nudge letters in em.

line-height sets the height of each line of text. Long reading text is comfortable at about 1.4 to 1.6 times the font size; big headings look better tighter, around 1.1 to 1.25.

Use a unitless number, and the reason is inheritance:

  • line-height: 1.5 passes the factor down. Each element multiplies it by its own font size.
  • line-height: 1.5em or 24px is converted to a length once, on the element where you set it, and that fixed length is what children inherit.
body {
  font-size: 1rem;
  line-height: 1.5;   /* every element gets 1.5 × its own size */
}
h1 {
  font-size: 2.5rem;
  line-height: 1.15;
}

The spacing properties fine-tune the gaps inside a line:

  • letter-spacing adds space between characters. Small caps and all-caps labels read better with a little extra, such as 0.05em. Using em means the gap scales with the text.
  • word-spacing adds space between words. Rarely needed, but handy for spaced-out labels.
  • text-transform changes the displayed case, such as uppercase, without changing the text in the HTML.
.site-nav a {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

The HTML still says "Menu" and "Visit"; only the display shows "MENU" and "VISIT", so the words stay easy to edit and translate.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.