ForHosting KIT · Documents & PDF

Recommend CSS line height for a font size and content type

Body text at 16 px gets a line height of 1.5, or 24 px, while headings use 1.2 and captions 1.4: enter a font size and the kind of text, and copy a ready starting value for your styles. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Font size
16
Content type
Body text
You get
Font size px
16
Recommended ratio
1.5
Line height px
24
Css
line-height: 24px;

This CSS line-height recommendation tool turns a font size and a typography role into a practical starting value. Choose body text, heading, or caption, and it applies a common role-specific ratio before returning both the unitless recommendation and its pixel equivalent. It is useful when a design begins with font sizes but has no established vertical-rhythm tokens yet. The result is deterministic, easy to copy into CSS, and intentionally presented as guidance rather than a claim about the unique perfect setting for every font.

Choose the content role before choosing the spacing

Line height should respond to how text is read, not merely repeat one multiplier across an entire interface. Body text usually spans several lines and must support comfortable tracking from the end of one line to the beginning of the next, so this tool recommends a ratio of 1.5. Headings are normally shorter, larger, and often limited to one or two lines; a tighter ratio of 1.2 preserves their visual unity and avoids turning a wrapped title into disconnected blocks.

Captions are smaller but generally brief, so the recommendation uses 1.4, giving compact text enough air without making it dominate nearby media or controls. Select the semantic role that describes the text's actual job. Use heading for titles and section labels that employ display-size type.

Use caption for image notes, figure labels, timestamps, and short secondary annotations.

Understand the returned ratio and pixel value

The recommendation is calculated by multiplying the positive font size in CSS pixels by the fixed ratio for the selected content type. A sixteen-pixel body size uses 1.5 and therefore returns twenty-four pixels. A thirty-two-pixel heading uses 1.2 and returns thirty-eight point four pixels.

The unitless ratio is often the better production value because CSS lets it inherit proportionally when descendants change font size. The pixel result is still valuable for design handoff, static specifications, visual QA, email templates, and token systems that require explicit lengths. Results are rounded to four decimal places so fractional sizes remain useful without exposing floating-point noise.

Input must be a positive finite number; zero, negative numbers, missing values, infinity, and nonnumeric strings produce an invalid-input error. Remember that the returned number represents a recommended line box, not the visible height of a glyph. Fonts distribute ascenders, descenders, and internal leading differently, which is why two typefaces at the same font size and line height can still appear more open or more crowded.

Treat the arithmetic as a reliable baseline for comparison and implementation, then inspect actual rendered text before finalizing a system-wide token.

Test the recommendation in the real layout

After generating a recommendation, place it in the layout where the text will actually appear and test representative content rather than a single polished sentence. For body text, include several paragraphs, long links, emphasized phrases, numbers, and narrow mobile widths. Check whether readers can move between lines without losing their place and whether the paragraph still feels connected as a whole.

For headings, test the longest realistic title at every responsive breakpoint. A ratio of 1.2 often creates a strong display block, but a typeface with unusually tall accents or a heading that wraps to three lines may need more space. For captions, inspect dense cards, image credits, table notes, and localized strings because small text can become tiring when line boxes are compressed.

Also check zoomed views and user-selected font substitutions where possible. Adjustments should become deliberate design tokens rather than scattered one-off CSS declarations. For example, start with the recommended ratio, record a tested exception for a particular display family, and apply that exception consistently to matching components.

This capability does not measure font metrics, line length, language, weight, or rendering environment, so it cannot replace visual review or accessibility testing. Its value is giving teams a sensible, explainable starting point and a repeatable calculation.

Start a typography scale

Turn chosen font sizes into initial body, heading, and caption line-height tokens before visual refinement.

Generate design documentation

Produce consistent ratios, pixel values, and CSS declarations for a component library or handoff sheet.

Validate content-role mappings

Reject unknown typography roles in an automated pipeline instead of allowing silent fallback spacing.

Which ratios does the tool recommend?

It uses 1.5 for body text, 1.2 for headings, and 1.4 for captions.

Should I use the ratio or the pixel value in CSS?

A unitless ratio usually inherits more safely, while the pixel value is convenient for fixed specifications and design handoff.

Is this a guarantee that text will be accessible?

No. It supplies a common starting point; test the actual font, line length, layout, zoom behavior, and content.

What line height should I use for 16 px body text?

A line height of 1.5, which is 24 px. Body text spans several lines, so the extra space helps the eye travel from the end of one line to the start of the next.

Why do headings get a tighter line height than paragraphs?

Headings are larger, shorter and often wrap onto one or two lines. A ratio of 1.2 keeps a wrapped title visually together, so a 32 px heading gets 38.4 px.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/doc/line-height-recommend

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/doc/line-height-recommend \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"font_size":16,"content_type":"body_text"}'
{
  "font_size": 16,
  "content_type": "body_text"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "doc.line_height_recommend",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_mb25
max_pages200
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Run it in the browser while designing, or use the API for $0.002 per request in token generators and automated documentation.

Choose the content role before choosing the spacing

Use body_text for paragraphs, articles, descriptions, and other sustained reading. The calculator normalizes the phrase body text to body_text, but rejects every other unrecognized content type instead of silently guessing. That explicit error matters in automated token pipelines because a misspelled role should be corrected at its source, not converted into an accidental default. These ratios are practical starting points based on common typographic patterns, leaving room for informed adjustment after the chosen font and layout are visible.

Understand the returned ratio and pixel value

The response includes the normalized font size, normalized content type, recommended ratio, calculated line_height_px, and a ready-to-copy CSS declaration. The computation has no network dependency, model call, random choice, or clock access, so identical requests always produce identical JSON.

Test the recommendation in the real layout

Interactive use is available in the browser, while an API request costs $0.002; both paths use the same deterministic function, making the recommendation suitable for documentation builds, token generation, code review checks, and design-system prototypes.

Which content types are recognized?

The accepted roles are body_text (or body text), heading, and caption. Other values return invalid_input.

What does an API request cost?

Each API request costs $0.002. The browser tool can be used interactively on the page.

Read the full KIT documentation →