Line Height and Text Spacing Best Practices
- CSS Basics
- Selectors & Specificity
- Box Model & Units
- Typography & Text Styling
- Colors & Color Spaces
- Positioning & Stacking Context
- Flexbox
- Grid
- Grid Advanced
- Responsive Design
- Container Queries
- Pseudo-classes & Pseudo-elements
- Modern Selectors
- CSS Custom Properties
- CSS Functions
- Transitions & Animations
- Transforms
- Forms & Input Styling
- CSS Architecture & Methodologies
- Accessibility in CSS
- Performance & Optimization
- View Transitions & Modern APIs
- Cascade Layers & Scope
What line-height Controls
line-height sets the vertical space a line of text occupies, which directly affects how readable a paragraph feels. Too tight, and lines feel cramped; too loose, and text feels disconnected.
p {
font-size: 1rem;
line-height: 1.6;
}Why Unitless Values Are Recommended
Writing line-height as a plain number (like 1.6) rather than a fixed unit means it is calculated as a multiple of that element's own font size. If a heading nested inside has a larger font size, its line height scales automatically instead of inheriting a fixed pixel value that no longer fits.
/* Recommended */
body { line-height: 1.5; }
/* Avoid: fixed value does not adapt if font-size changes on children */
body { line-height: 24px; }Letter Spacing and Word Spacing
| Property | Effect | Common use |
|---|---|---|
letter-spacing | Space between individual characters | Small uppercase labels, logos |
word-spacing | Space between whole words | Rarely needed; can hurt readability if overused |
General Readability Guidelines
- Body text usually reads best around
1.5to1.6line-height. - Headings can use a tighter line-height (around
1.1-1.3) since they wrap less. - Long lines of text (past roughly 75-80 characters) become harder to read no matter the line-height, so pairing spacing with a sensible
max-widthmatters just as much.