🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEcss

css Documentation

LOADING ENGINE...

CSS Line Height

Master vertical rhythm. Learn why unitless values are the gold standard for readable typography.

style.css
p {
font-size: 16px;
line-height: 1.5;
/* 16 * 1.5 = 24px */
}
style.css
1 / 8
📐

Tutor:Line-height defines the amount of space above and below inline elements. It's crucial for readability, also known as 'leading'.


Typography Mastery

Unlock nodes by learning spacing and vertical rhythm.

Concept 1: What is Line Height?

line-height defines the amount of space used for lines, such as in text. On block-level elements, it specifies the minimum height of line boxes within the element.

System Check

What happens if line-height is smaller than the font-size?


Community Holo-Net

Share Typography Stacks

Found the perfect font/leading combination? Share your snippets.

Enjoying this guide?

Codesyllabus is 100% free and open-source. Support our mission, pay for server infrastructure, and fuel new tutorials by buying us a coffee!

CSS Line Height

Author

Pascual Vila

Frontend Instructor.

The line-height property is the most significant factor in vertical rhythm and readability. It controls the space between lines of text. A well-set line height can make long paragraphs readable, while a poor one can make text feel cramped or disjointed.

The Golden Rule: Unitless Values

While you can use px, em, or percentages, the best practice is to use a unitless number (e.g., 1.5).

/* Recommended */ line-height: 1.5; /* Avoid for main text */ line-height: 24px;

Unitless values act as a multiplier of the current element's font-size. Crucially, they solve inheritance issues. If a parent has line-height: 1.5, a child with a larger font size will recalculate its line height based on its own font size, not the parent's fixed pixel value.

Calculating Line Height

The browser calculates the used value by multiplying the element's computed font size by the unitless value.

  • Font Size: 16px
  • Line Height: 1.5
  • Result: 24px per line

Accessibility & WCAG

The Web Content Accessibility Guidelines (WCAG) recommend a line height of at least 1.5 (150%) for body text to ensure content is readable for people with cognitive disabilities or visual impairments.

Typography Glossary

Leading
A print typography term for the vertical distance between baselines of type. In CSS, this is handled by line-height.
Unitless Value
A number without a unit (like 1.5 vs 24px). It allows the line-height to scale relative to the element's own font size.
Vertical Rhythm
The consistent spacing and arrangement of text and elements vertically on a page, primarily established by line-height and margin.