Free • Fast • Privacy-first

CSS Line Height Generator

Control vertical spacing between lines for perfect readability

Our free CSS line height generator lets you visually set line-height and preview the result on a real paragraph. Supports unitless, px, em, and % values. Copy the CSS instantly.

Range
0.5 – 3.0
Units
4 options
Preview
Paragraph
Privacy
100% Local

The quick brown fox jumps over the lazy dog. Line-height controls the vertical space between these lines.

CSS Line Height Generator

Adjust the slider and type your sample paragraph.

Line Height Control

1.5
0.53.0

Recommended: unitless values inherit correctly in child elements

Preview

The quick brown fox jumps over the lazy dog. CSS line-height controls the vertical space between lines of text, which has a major impact on readability and typographic rhythm.

CSS Code

line-height: 1.5;

What is CSS line-height?

CSS line-height specifies the height of a line box, controlling the amount of space above and below inline elements. In typography this is called "leading". A unitless value (like 1.5) is multiplied by the element's font-size to compute the actual height. This is the recommended approach because child elements inherit the multiplier, not the computed value.

According to MDN Web Docs, a line-height of 1.5 is the W3C accessibility guideline minimum for body text. Professional typography typically ranges from 1.4 to 1.8 depending on font and context.

For related typography tools see our CSS Letter Spacing and CSS Word Spacing generators.

How it Works

  1. 1
    Adjust Slider
    Set line-height from 0.5 to 3.0.
  2. 2
    Select Unit
    Pick unitless (recommended), px, em, or %.
  3. 3
    Edit Paragraph
    Paste your own text to see the real impact.
  4. 4
    Copy CSS
    Copy the generated property instantly.

Frequently Asked Questions

What is CSS line-height?

CSS line-height controls the vertical distance between lines of text, also called "leading" in typography. It can be set as a unitless number (multiplied by font-size), a length in px/em/rem, or a percentage. It affects the total height of each line box, distributing space above and below the text equally.

What is the recommended line-height for body text?

The WCAG accessibility guidelines recommend a line-height of at least 1.5 for body text. Most design systems and style guides suggest values between 1.4 and 1.8 depending on the font. Wider fonts and larger text sizes benefit from slightly lower values; narrow or small fonts benefit from higher values.

Why is unitless line-height recommended?

Unitless line-height (e.g., line-height: 1.5) is recommended because it scales proportionally with the inherited font-size of child elements. If you use a length value like 20px, child elements that inherit the line-height will use 20px regardless of their own font-size, which can cause overlapping or cramped text. Unitless values prevent this inheritance problem.

What is the difference between line-height and margin?

line-height adds space above and below the text within the same line box, creating leading. margin adds space outside the element's border box, pushing surrounding elements away. For spacing between paragraphs, use margin-bottom. For spacing within a paragraph (between lines), use line-height. Mixing both gives you full control over typographic rhythm.

How does line-height affect readability?

Line-height has a direct impact on readability. Too tight (below 1.3) makes lines visually merge; too loose (above 2.0) makes it hard for the eye to track to the next line. Optimal line-height depends on line length — wider columns (80+ characters) benefit from more generous line-height to help the eye move across longer lines.

Can I use line-height for vertical centering?

Yes, for single-line text you can set line-height equal to the container height to vertically center text. For example, a 40px tall button with line-height: 40px will center single-line text. This technique is simple but only works for single lines. For multi-line text, use flexbox or grid centering instead.

What browsers support CSS line-height?

CSS line-height is supported in all browsers since the very early days of CSS. It requires no vendor prefixes and works consistently across Chrome, Firefox, Safari, Edge, and all mobile browsers. It is one of the most universally supported CSS properties.

Is this line height generator free?

Yes, the CSS Line Height Generator is completely free. No registration, no ads requiring interaction, no limit on usage. All computation runs in your browser so your content never leaves your device. Use it for personal and commercial projects alike.