Understanding CSS Line-Height
The line-height CSS property sets the height of a line box, which determines the vertical space between lines of text. This fundamental property affects readability, accessibility, and the overall visual hierarchy of your content. Unlike many CSS properties that default to zero or browser-specific values, line-height has a default of normal, which computes to approximately 1.2 depending on the element's font-family, as documented in the MDN Web Docs.
Understanding line-height requires knowing how browsers render text. Each line of text occupies a "line box," and the line-height property controls the height of this box. The space above and below the actual font is distributed evenly, meaning a line-height of 1.5 on 16px text creates 8px of space above and 8px below each line. This vertical rhythm, when consistent throughout a design, creates a professional and harmonious reading experience.
The line-height property accepts several value types, each with distinct behavior. The normal keyword allows the browser to compute a reasonable value, typically around 1.2 for most fonts. Unitless numbers multiply the element's font-size, making them the recommended approach for most use cases. Fixed lengths (px, em, rem) and percentages calculate to absolute pixel values, which can cause inheritance issues we'll explore later.
Mastering these fundamentals is essential for any professional web development project, ensuring typography scales correctly across all devices and user preferences.
1/* Keyword */2line-height: normal;3 4/* Unitless number (recommended) */5line-height: 1.5;6line-height: 1.6;7 8/* Length units */9line-height: 24px;10line-height: 1.5em;11line-height: 1.5rem;12 13/* Percentage */14line-height: 150%;Why Unitless Values Are Essential
One of the most important lessons in CSS typography is to use unitless values for line-height. The reason stems from how CSS inheritance works with calculated values versus multipliers, as explained in this technical guide on unitless line-height values.
When you set line-height: 1.5rem on the body element with a 16px font size, the browser calculates and stores 24px. This computed pixel value is then inherited by all child elements, regardless of their font-size. A heading at 4rem (64px) would inherit 24px line-height--far too tight for proper readability. The h1 would have only 24px of line space for 64px of text, causing overlapping and accessibility issues.
Unitless values solve this elegantly. Setting line-height: 1.5 on body means each child element multiplies its own font-size by 1.5. The h1 at 64px gets a 96px line-height (1.5 × 64), while paragraphs at 32px get 48px (1.5 × 32). This automatic scaling maintains proportional spacing across all text sizes without additional declarations, as demonstrated by Kevin Powell's line-height guidance.
This inheritance behavior is why experienced developers always prefer unitless values for line-height. It creates predictable, scalable typography that adapts to each element's font-size automatically, reducing the need for overrides and specific declarations.
For teams working with modern CSS-in-JS solutions like Vanilla Extract, this pattern becomes especially valuable for maintaining consistent type scales across your entire codebase.
1/* Problematic: Fixed inheritance */2body {3 font-size: 1rem; /* 16px */4 line-height: 1.5rem; /* 24px fixed - inherited! */5}6h1 { font-size: 4rem; } /* 64px text, but only 24px line-height */7 8/* Solution: Scalable inheritance */9body {10 font-size: 1rem;11 line-height: 1.5; /* 1.5 multiplier - recalculated per element */12}13h1 { font-size: 4rem; } /* 96px line-height (1.5 × 64) */Recommended Line-Height Values
Different content types require different line-height values to achieve optimal readability. These recommendations balance typographic principles with accessibility requirements, as outlined by Kevin Powell's line-height guidance.
Body Text
For paragraph content and main reading text, a line-height between 1.4 and 1.6 is ideal. The Web Content Accessibility Guidelines (WCAG) recommend a minimum of 1.5 for paragraph content to ensure readability for people with visual impairments or cognitive differences. Most designers find 1.5 to 1.6 provides excellent readability for body copy at standard screen sizes.
Headings and Large Text
Headings require tighter line-height than body text. When font-size increases, the line-height needs to decrease proportionally to maintain visual balance. A line-height of 1.1 to 1.3 works well for headings, preventing the excessive whitespace that occurs when body-text line-height is applied to large text.
Uppercase Text
Text rendered in all caps has no descenders (the parts of letters like g, y, p that extend below the baseline), which creates awkward gaps when using standard line-height. Uppercase labels, navigation items, and button text typically need line-height of 1.0 to 1.2 to appear visually balanced and prevent the "double-spaced" appearance that occurs when descender space goes unused.
Narrow Columns and Dense Content
Content in narrow columns or mobile layouts benefits from increased line-height to improve readability. A line-height closer to 1.7 or 1.8 can help readers track from the end of one line to the beginning of the next, especially when line length is under 60 characters.
These typography principles are foundational to accessible web design, ensuring your content is readable by all users regardless of device or ability.
Choose the right line-height for each content type
Body Text (1.4-1.6)
Standard paragraph content. 1.5 is the WCAG minimum accessibility requirement.
Headings (1.1-1.3)
H1 through H6 elements. Tighter spacing prevents excessive whitespace.
Uppercase Text (1.0-1.2)
Labels, navigation, buttons. No descenders means less space needed.
Narrow Columns (1.7-1.8)
Mobile layouts, sidebars. More spacing helps readers track lines.
Accessibility Considerations
Accessibility is not optional--it's a fundamental aspect of quality web development. Line-height plays a crucial role in making content accessible to users with various visual and cognitive differences. WCAG 2.2 Success Criterion 1.4.8 specifies that paragraph spacing should be at least 1.5 times the line-height, as documented in Kevin Powell's line-height guide.
The minimum line-height of 1.5 for body text is not arbitrary. Users with low vision who zoom text, individuals with dyslexia who benefit from clear visual separation between lines, and people using screen magnifiers all depend on adequate line spacing. When line-height is too small, text becomes dense and difficult to track, causing eye strain and comprehension challenges.
Implementing accessible line-height is straightforward: start with a unitless value of 1.5 or higher for body content, and ensure that when users increase browser font size or zoom the page, the proportional spacing is maintained. Avoid fixed pixel values that break scaling behavior.
Proper typography, including adequate line-height, is a key component of accessible web design that serves all users effectively.
Common Pitfalls and Solutions
Overriding Line-Height on Headings
A frequent mistake is leaving inherited line-height on headings without adjustment. Body-text line-height (1.5-1.6) creates excessive vertical space for large headings, disrupting the visual hierarchy. Always set tighter line-height on heading elements to maintain proper proportions.
Using Pixels for Responsive Typography
Setting line-height in pixels prevents text from scaling proportionally when users adjust browser font size or zoom the page. This breaks accessibility and creates inconsistent typography at different zoom levels. Always use unitless values for line-height to maintain proportional scaling.
Neglecting Form Elements
Form inputs, buttons, and other replaced elements may need explicit line-height declarations to ensure text remains vertically centered and readable. The inherited line-height from body may not work correctly with input padding and height.
Inconsistent Vertical Rhythm
When different sections of a page use inconsistent line-height values, the overall design feels disjointed. Establish a typographic scale and apply it consistently throughout your design system to create a cohesive visual experience.
These pitfalls are common even in production websites, but they're easily avoided with proper planning and CSS architecture that enforces consistent typography standards.
1/* Mistake 1: Headings inherit body line-height */2h1, h2, h3, h4, h5, h6 {3 line-height: 1.5; /* Too loose for headings */4}5 6/* Fix: Tighter line-height for headings */7h1, h2, h3, h4, h5, h6 {8 line-height: 1.2;9}10 11/* Mistake 2: Fixed pixel values */12p {13 line-height: 24px; /* Doesn't scale */14}15 16/* Fix: Unitless values */17p {18 line-height: 1.6;19}20 21/* Mistake 3: Inherited line-height on form elements */22input, button {23 /* May need explicit line-height */24 line-height: normal;25}Performance and Best Practices
From a performance perspective, line-height is a highly optimized CSS property that doesn't impact rendering performance significantly. The browser calculates line boxes during the layout phase, and modern engines handle these calculations efficiently. However, maintaining a consistent typography system through CSS custom properties can improve maintainability and reduce CSS bundle size.
Using CSS custom properties for typography creates a centralized system that ensures consistency and makes updates efficient. This approach aligns with modern CSS architecture patterns and makes your typography system scalable and maintainable. When you define line-height values as variables, you can update the entire site's typography from a single location, reducing the risk of inconsistencies.
A well-architected typography system also supports responsive design more effectively. By using relative units and CSS custom properties, you can adjust line-height values at different breakpoints without hunting through multiple CSS declarations, as demonstrated in CSS-Tricks' line-height almanac.
For teams building modern web applications, establishing typography standards early prevents technical debt and ensures consistent user experiences across all pages. This foundational work pays dividends as your project grows and evolves.
1:root {2 --line-height-body: 1.6;3 --line-height-heading: 1.2;4 --line-height-tight: 1.1;5}6 7body {8 line-height: var(--line-height-body);9}10 11h1, h2, h3, h4, h5, h6 {12 line-height: var(--line-height-heading);13}14 15.label-uppercase {16 line-height: var(--line-height-tight);17}Summary and Implementation Guide
Mastering font text height through proper line-height usage transforms cramped, hard-to-read text into comfortable, professional typography. The key principles are:
- Always use unitless values for line-height to ensure proper inheritance and scaling
- Apply 1.4-1.6 line-height to body text, with 1.5 as the WCAG minimum
- Use tighter line-height (1.1-1.3) for headings and large text
- Reduce line-height for uppercase text without descenders
- Test typography at different zoom levels to ensure accessibility
By implementing these practices, your websites will deliver superior readability, meet accessibility standards, and present a polished professional appearance that enhances user experience across all devices. Proper typography is a hallmark of quality web development that sets professional sites apart.
If you're building a new website or redesigning an existing one, establishing proper typography fundamentals like line-height early in the process saves time and ensures consistency throughout the project. Our web development services can help you implement these best practices across your entire digital presence.
Frequently Asked Questions
What is the minimum accessible line-height for body text?
WCAG 2.2 recommends a minimum line-height of 1.5 for paragraph content. This ensures readability for users with visual impairments and those using screen magnifiers.
Should I use px, em, rem, or unitless for line-height?
Always use unitless values (e.g., 1.5, not 1.5rem or 24px). Unitless values scale proportionally with font-size, maintaining consistent typography across all text sizes without additional declarations.
Why do headings need different line-height than body text?
Larger text requires tighter line-height to maintain visual balance. Body-text line-height creates excessive whitespace on headings, disrupting the visual hierarchy.
Does line-height affect accessibility?
Yes. Inadequate line-height can make text difficult to read for users with low vision, dyslexia, or cognitive differences. WCAG requires a minimum of 1.5 for paragraph content.
Sources
- MDN Web Docs: line-height - Official CSS specification reference for line-height property syntax and values
- Kevin Powell: You need to fix your line-height - Practical guidance on recommended values and accessibility considerations
- CSS-Tricks: line-height Almanac - Comprehensive guide to line-height property behavior
- Playful Programming: Unitless line-height values - Technical explanation of inheritance behavior with different value types