Line Height Calculator

Calculate optimal line height for readable typography. Get leading values and readability recommendations.

Typography Settings

Preview

The quick brown fox jumps over the lazy dog. Typography is the art and technique of arranging type to make written language legible, readable and appealing when displayed.

Line Height (px)
24.00px
Unitless
1.500
Leading
8.00px
Half Leading
4.00px

CSS Code

line-height: 1.5;
/* 24.00px at 16px font size */

Line Length Analysis

Current width: 600px (~75 characters)

Optimal range: 360px - 600px

(45-75 characters recommended for readability)

What Is Line Height in Typography?

Line height — known as leading in traditional typesetting — is the vertical distance from the baseline of one line of text to the baseline of the next. It directly governs how open or cramped a block of text feels, and it is one of the most impactful readability levers available to web designers and developers.

In CSS the property is simply called line-height. It can be specified as a unitless multiplier (e.g. 1.5), in pixels (24px), in em units (1.5em), or as a percentage (150%). Each notation calculates the same final pixel value differently, which is why a line height calculator is so useful — it translates between all four units instantly and shows the resulting pixel height, leading gap, and half-leading for any combination of font size and line-height value you enter.

When type was set in physical metal, compositors inserted thin strips of lead between rows to add spacing — hence "leading." Modern CSS inherited the concept but extended it: the browser divides the calculated space above and below each line of text into equal halves (called half-leading), distributing them symmetrically around the em square. This means even a single value like line-height: 1.5 has a precise geometric meaning tied to the font size in use.

Good line height balances two competing needs: lines must be far enough apart that the eye can track from the end of one line back to the start of the next without confusion, but close enough that the text block reads as a coherent unit rather than a collection of isolated stripes. For body copy at typical web sizes (14–20 px), values between 1.4 and 1.6 hit this sweet spot for most typefaces. Headings, which are set larger and in shorter lines, typically use tighter values around 1.1–1.3.

This calculator lets you explore every aspect of CSS line height: enter a font size, choose a unit, adjust the value, and see the pixel equivalent, unitless ratio, leading, and half-leading recalculate in real time. The live preview and line-length analysis help you confirm your settings will look great before you touch a single line of CSS.

Line Height Formulas and Calculations

The calculator supports four CSS line-height units. Each maps to pixel values and a unitless ratio using the formulas below. The leading is the extra space between lines beyond the font's cap height — it equals the absolute line height in pixels minus the font size in pixels. The half-leading is that gap split evenly above and below the text content area.

Understanding the unit conversions helps you choose the right notation for your project. Unitless values are the recommended approach in CSS because they scale proportionally when a child element inherits a different font size — the child multiplies its own font size by the ratio rather than inheriting a fixed pixel value. Pixel values lock the row height absolutely, which is useful for precise grid alignment but breaks with fluid typography. Em and percentage units behave identically to unitless in the parent element but, unlike unitless, they inherit the computed pixel value rather than the ratio, which can cause tight stacking in nested elements.

Unit Line Height (px) Unitless Ratio
Unitless lineHeight × fontSize lineHeight
Pixels (px) lineHeight lineHeight ÷ fontSize
EM lineHeight × fontSize lineHeight
Percentage (%) (lineHeight ÷ 100) × fontSize lineHeight ÷ 100

Line Height Core Formulas

lineHeightPx (unitless) = lineHeight × fontSize lineHeightPx (px) = lineHeight lineHeightPx (em) = lineHeight × fontSize lineHeightPx (%) = (lineHeight / 100) × fontSize leading = lineHeightPx − fontSize halfLeading = leading / 2 optimalMinWidth = 45 × (fontSize × 0.5) optimalMaxWidth = 75 × (fontSize × 0.5) charsPerLine = round(containerWidth / (fontSize × 0.5))

Where:

  • lineHeight= The numeric line-height value you enter (1.5, 24, 1.5em, 150%, etc.)
  • fontSize= Font size in pixels (e.g. 16)
  • lineHeightPx= Absolute line height converted to pixels
  • leading= Extra vertical space between text rows (lineHeightPx − fontSize)
  • halfLeading= Leading divided equally above and below the content area
  • optimalMinWidth= Container width that fits 45 characters at this font size (readability lower bound)
  • optimalMaxWidth= Container width that fits 75 characters at this font size (readability upper bound)
  • charsPerLine= Estimated characters per line given the container width (uses avgCharWidth = fontSize × 0.5)

Unitless vs. Fixed Line Height: Which Should You Use?

The CSS specification recommends using unitless line-height values for almost every use case, and for good reason. When you write line-height: 1.5, the browser multiplies the current font size by 1.5 to compute the row height. If a child element has a different font size, it performs the same multiplication with its own font size — so line spacing stays proportionally correct throughout your component tree.

Fixed pixel values like line-height: 24px lock every row to 24 px regardless of font size. This looks fine at the size you designed for, but it breaks as soon as users increase their browser's base font size (an accessibility concern) or when a child element inherits a font size that's larger than the row height, causing text to overlap. Similarly, 1.5em and 150% compute identically to the unitless value in the element where they are set, but they pass the already-computed pixel value to children rather than the multiplier — a subtle inheritance trap that trips up many developers.

The practical advice for most projects: use a unitless value between 1.4 and 1.6 for body copy and between 1.1 and 1.3 for headings. Reserve pixel values for situations where you need exact row alignment — for example, a code block that must align with a grid. Use em or percentage only when you explicitly want the inherited-pixel-value behavior (rare). This calculator's presets (Tight 1.2, Normal 1.5, Relaxed 1.75, Loose 2.0) cover the most common editorial and UI type-setting scenarios.

Accessibility guidelines from WCAG 2.1 recommend that line spacing is at least 1.5 times the font size within paragraphs, and that paragraph spacing is at least 2 times the font size — requirements that map directly to the unitless values this tool calculates. Using this line height calculator ensures you meet those thresholds before publishing.

Optimal Line Length and Readability

Line height does not work in isolation — it is deeply intertwined with line length, the number of characters that fit horizontally on a single line of text. Typography research consistently points to a sweet spot of 45–75 characters per line for comfortable reading of body copy (some sources extend the range to 45–85 for wider screens). Shorter lines feel choppy and make the eye jump constantly; longer lines cause fatigue because the reader has to travel far horizontally and then find the start of the next line.

This calculator estimates the characters-per-line count using a simple heuristic: the average character width is approximated as 50% of the font size (avgCharWidth = fontSize × 0.5). This gives a reasonable first approximation for proportional Latin typefaces. The optimal container widths are then:

  • Minimum readable width: 45 × (fontSize × 0.5) = 22.5 × fontSize
  • Maximum readable width: 75 × (fontSize × 0.5) = 37.5 × fontSize

For a 16 px font the optimal column is between 360 px and 600 px wide — matching the conventional wisdom of setting body copy containers to around 600–700 px and capping them with max-width. For a 18 px font the range shifts to 405–675 px. The "Line Length Analysis" panel in the calculator shows where your current container width falls relative to these bounds and flags it when you stray outside the recommended range.

Adjusting line height in response to line length is also good practice. Very narrow columns (under 45 characters) can tolerate slightly looser line spacing — say 1.6 — because the reader's eye must jump back to the left more frequently and extra vertical air helps with orientation. Conversely, wide lines benefit from a touch more space as well, to give the eye a clear path back. The sweet spot stays around 1.5 for the 45–75 character range.

CSS Line Height Best Practices for Web Typography

Applying line height effectively goes beyond picking a single number. Here are the most impactful best practices distilled from typographic standards and real-world CSS work:

Set a global base on the body element

Applying line-height: 1.5 directly on the body element lets all paragraph text inherit a solid default. Override it for headings, code, and UI elements that need different spacing. This keeps your CSS concise and avoids per-element repetition.

Tighten headings, loosen body

Headings are short, large, and scan quickly — they work best with line-height between 1.1 and 1.3. Body paragraphs are long and require sustained reading — stay in the 1.4–1.6 range. Captions, labels, and UI micro-copy often sit comfortably at 1.3–1.4.

Match line height to your grid

On projects using an 8 px baseline grid, choose a font size and line height combination whose pixel value is a multiple of 8. For example, 16 px font with line-height 1.5 gives 24 px rows — three units on an 8 px grid. Use the pixel output from this calculator to confirm alignment before writing the CSS.

Test with real text at real sizes

Numbers alone won't tell you if a setting looks good. Always fill the preview panel with representative copy and check both desktop and mobile viewport widths. What reads well at 600 px may feel cramped at 360 px if the container scales without media query overrides.

Respect user preferences

Some users apply custom browser stylesheets or operating-system font-size adjustments. Unitless line heights handle these gracefully; avoid !important on line-height rules so user-agent overrides can still take effect for accessibility needs.

Comparing Line Height Units: px, em, %, and Unitless

Choosing the right unit notation for line-height affects maintainability, accessibility, and how values cascade through your component tree. The table below summarizes the trade-offs:

Unit Example Inheritance Best Used For
Unitless 1.5 Passes the multiplier (safe) Body text, global defaults
Pixels 24px Fixed px (watch for overlap) Grid-aligned code blocks
EM 1.5em Passes computed px (risk) Single-element overrides
Percentage 150% Passes computed px (risk) Inline styles, legacy code

For new projects, standardize on unitless values throughout. Use this line height calculator to quickly convert any existing pixel or percentage values to their unitless equivalents — simply enter the font size and the pixel line height, select the "px" unit, and read the Unitless column in the results.

Worked Examples

Standard Body Text (Unitless)

Problem:

A paragraph is set at 16 px with a unitless line-height of 1.5. What are the line height in pixels, the leading, and the half-leading? Is a 600 px container within the optimal line-length range?

Solution Steps:

  1. 1Line height in pixels (unitless): lineHeightPx = lineHeight × fontSize = 1.5 × 16 = 24 px
  2. 2Unitless ratio: 1.5 (same as the input for unitless mode)
  3. 3Leading: lineHeightPx − fontSize = 24 − 16 = 8 px
  4. 4Half-leading: leading / 2 = 8 / 2 = 4 px (distributed above and below each text row)
  5. 5Average character width: fontSize × 0.5 = 16 × 0.5 = 8 px
  6. 6Characters per line: round(600 / 8) = 75 — right at the upper bound of the 45–75 character range
  7. 7Optimal min width: 45 × 8 = 360 px; optimal max width: 75 × 8 = 600 px — the container sits exactly at the maximum optimal width

Result:

CSS: line-height: 1.5 — computes to 24 px rows, 8 px leading, 4 px half-leading. The 600 px container fits ~75 characters, sitting at the top of the recommended reading-width range.

Large Heading (Unitless, Tight Spacing)

Problem:

A heading is set at 32 px with a unitless line-height of 1.2. What are the pixel line height, leading, and half-leading?

Solution Steps:

  1. 1Line height in pixels: lineHeightPx = 1.2 × 32 = 38.4 px
  2. 2Unitless ratio: 1.2 (tight, suitable for large display type)
  3. 3Leading: 38.4 − 32 = 6.4 px
  4. 4Half-leading: 6.4 / 2 = 3.2 px added above and below the heading's content area
  5. 5Average character width for 32 px type: 32 × 0.5 = 16 px
  6. 6Optimal min width: 45 × 16 = 720 px; optimal max width: 75 × 16 = 1,200 px

Result:

CSS: line-height: 1.2 — computes to 38.4 px rows, 6.4 px leading, 3.2 px half-leading. The tight ratio is appropriate for headings; body text at this ratio would be flagged as too tight by the calculator.

Body Text Using Pixel Unit

Problem:

A designer specifies a fixed line height of 28 px for 18 px body text. Convert to a unitless ratio and find the leading and half-leading.

Solution Steps:

  1. 1Unit mode: px — lineHeightPx = 28 px (the value directly)
  2. 2Unitless ratio: lineHeight / fontSize = 28 / 18 ≈ 1.556
  3. 3Leading: lineHeightPx − fontSize = 28 − 18 = 10 px
  4. 4Half-leading: 10 / 2 = 5 px
  5. 5Average character width: 18 × 0.5 = 9 px
  6. 6For a 700 px container: charsPerLine = round(700 / 9) = round(77.8) = 78 — slightly over the recommended 75-character maximum

Result:

CSS: line-height: 28px — unitless equivalent ≈ 1.556, leading 10 px, half-leading 5 px. The 700 px container yields ~78 characters per line, marginally above the 75-character readability ceiling.

Using Percentage Mode

Problem:

A legacy stylesheet uses line-height: 150% on 14 px small-print text. What are the pixel line height, leading, and half-leading?

Solution Steps:

  1. 1Unit mode: % — lineHeightPx = (lineHeight / 100) × fontSize = (150 / 100) × 14 = 1.5 × 14 = 21 px
  2. 2Unitless ratio: lineHeight / 100 = 150 / 100 = 1.5
  3. 3Leading: 21 − 14 = 7 px
  4. 4Half-leading: 7 / 2 = 3.5 px
  5. 5Average character width: 14 × 0.5 = 7 px
  6. 6For a 420 px container: charsPerLine = round(420 / 7) = 60 — comfortably within the 45–75 range

Result:

CSS: line-height: 150% — computes to 21 px rows, 7 px leading, 3.5 px half-leading. Functionally identical to line-height: 1.5 in this element, but will cascade the computed 21 px to child elements rather than the 1.5 multiplier.

Tips & Best Practices

  • Use unitless line-height values (e.g. 1.5) on the body element as a global default — all text will inherit it and child elements won't break when their font size changes.
  • For headings, set line-height between 1.1 and 1.3; for body paragraphs, stay in the 1.4–1.6 range; for captions and UI labels, try 1.3–1.4.
  • WCAG 2.1 Success Criterion 1.4.12 (Text Spacing) requires line height of at least 1.5× the font size — always run accessibility-critical copy through this calculator to confirm compliance.
  • Use the pixel output from this calculator to snap line heights to your baseline grid (e.g. multiples of 8 px) so elements align cleanly across the layout.
  • Avoid px line heights for body text — they break when users increase their browser's base font size for accessibility. Unitless values scale automatically.
  • Pair your chosen line height with an optimal container width: for 16 px text aim for a container of 360–600 px; for 18 px text aim for 405–675 px (45–75 characters per line).
  • When using em or % units, remember they pass the already-computed pixel value to child elements — switch to unitless if your component has nested text at different font sizes.
  • Test line spacing on mobile viewports as well as desktop — a 1.5 ratio that looks relaxed at 1200 px can feel cramped on a 375 px screen where the container is narrower.
  • For code blocks and monospace type, a slightly larger line height (1.6–1.8) improves legibility because mono fonts have no typographic variation to guide the eye between lines.

Frequently Asked Questions

For most body copy at typical web font sizes (14–20 px), a unitless value between 1.4 and 1.6 is widely recommended. The Web Content Accessibility Guidelines (WCAG 2.1) specifically require that line spacing within paragraphs is at least 1.5 times the font size to meet the enhanced readability success criterion. Starting with 1.5 is a safe default and you can fine-tune from there based on your typeface's x-height and your container width.
A unitless value such as 1.5 is stored as a multiplier and passed to descendant elements, which re-apply it to their own font sizes. This means if a child element has a larger or smaller font size, its line spacing still scales proportionally — preventing text from overlapping or looking too cramped. By contrast, em and percentage values compute to a fixed pixel amount in the current element and that pixel amount is what children inherit, which can break spacing in nested components with different font sizes.
Leading (pronounced 'ledding', from the lead strips typesetters once inserted between rows) is the gap between consecutive lines of text — specifically the distance between the bottom of one line's content area and the top of the next line's content area. In this calculator, leading is calculated as lineHeightPx − fontSize. Line height is the full row height including that gap, while leading is just the gap itself. Half-leading is that gap split evenly above and below each row, which is how CSS actually distributes the extra space.
Most typographic authorities — including Robert Bringhurst's The Elements of Typographic Style and the Baymard Institute — recommend 45–75 characters per line for comfortable reading of body copy in Latin scripts. This calculator estimates characters per line using a 50% of font size approximation for average character width (charsPerLine = round(containerWidth / (fontSize × 0.5))). Lines shorter than 45 characters feel choppy and disrupt reading flow; lines longer than 75 characters increase eye strain as the reader scans back to the start of the next line.
Yes. Headings are typically displayed at larger font sizes and are read in short bursts rather than sustained paragraphs, so they benefit from tighter line spacing — usually between 1.1 and 1.3. At large sizes, excessive line height creates awkward gaps between heading lines that break the visual unity of a multi-line title. Body text, which requires sustained reading, needs more breathing room at 1.4–1.6. Subheadings and labels often sit in the middle, around 1.3–1.4.
Line height does not directly affect Core Web Vitals metrics, but it strongly influences user engagement signals that search engines use as indirect quality indicators. Text that is too cramped or too sparse increases bounce rate and reduces time on page. Ensuring readable line spacing — especially on mobile viewports — is also part of the Google mobile-usability requirements and contributes to a positive page experience. Using WCAG-compliant line spacing (≥ 1.5 for body text) is both an accessibility requirement and a best practice for reaching the widest possible audience.
Divide the pixel line height by the font size in pixels. For example, if your font size is 16 px and your line height is 24 px, the unitless equivalent is 24 ÷ 16 = 1.5. This calculator automates the conversion — simply enter the pixel value as the Line Height input, select the 'Pixels (px)' unit, and the Unitless result card shows the equivalent ratio instantly.
Half-leading is the result of the browser splitting the total leading (lineHeightPx − fontSize) into two equal portions: one placed above the content area of each text box and one placed below. It matters for precise vertical alignment because padding, margin, and flexbox/grid alignment are calculated relative to the text box edges, which include the half-leading. When you need a heading to optically align with an adjacent image, or when you need the first line of a paragraph to align with a baseline grid, knowing the half-leading value lets you add compensating negative margins or padding to achieve pixel-perfect results.

Sources & References

Last updated: 2026-06-05

💡

Help us improve!

How would you rate the Line Height Calculator?

<>

Editorial Note

MyCalcBuddy Editorial Team

This page is maintained as an educational calculator reference.

Source

Formula Source: Standard Mathematical References

by Various

UpdatedLast reviewed: May 2026
CheckedFormula checks are based on standard references and internal QA review.