Course contentsShow
← Web Development
Lesson 169 of 2,9823. CSS FundamentalsFree lesson

Line Height and Vertical Rhythm

Control spacing between lines with line-height to improve readability and establish vertical rhythm.

Line Height and Vertical Rhythm

What you'll learn: How to control the spacing between lines of text to make content more readable and visually harmonious.

What is Line Height?

Line height (controlled by the line-height property) determines the vertical space occupied by each line of text. Think of it like the ruled lines on notebook paper—you can write on every line, skip lines, or use paper with wider spacing. The distance between those lines affects how easy the text is to read.

How Line Height Works

When you set line-height, you're defining the total height of a line box, not just the space between lines. If your font-size is 16px and your line-height is 24px, each line gets 24 pixels of vertical space, with the extra space distributed equally above and below the text.

p {
  font-size: 16px;
  line-height: 1.5; /* 24px total line height */
}

Notice the unitless value 1.5—this multiplies the font size (16px × 1.5 = 24px). This is the preferred approach because it scales proportionally with different font sizes.

Establishing Vertical Rhythm

Vertical rhythm means maintaining consistent, harmonious spacing throughout your page. When line heights align to a predictable pattern, content feels organized and pleasant to read. Typically, you'll want more generous line height for body text (1.5–1.8) and tighter spacing for headings (1.1–1.3).

body {
  line-height: 1.6;
}

h1, h2, h3 {
  line-height: 1.2;
}

Readability Guidelines

Too tight, and text feels cramped. Too loose, and readers lose their place between lines. For body text, aim for 1.5 to 1.6 as a starting point.

Key Takeaway: Use the line-height property with unitless values (like 1.5) to control spacing between lines, improving readability and creating visual consistency across your design.