Building a type scale for a blog, from the body text up
A blog needs body text, a caption size, and headings for the post title, sections and subsections. Suppose the body is 16px, the post title should be about 48px on a laptop, and the scale should have five steps above the body. The question is which ratio gets there. Switch to Fit my largest heading and type 48, and the page works out the fifth root of 48 divided by 16, which is 1.2457. The nearest preset is the major third, 1.25.
With 1.25, the five steps are 20, 25, 31.25, 39.06 and 48.83 pixels. The top step is the post title. The fourth, 39px, is too close to it to be useful on the same page, so many designs skip it and use 31.25px for section headings and 25px for subsections. The 20px step suits a lead paragraph or a card title. Below the body, 12.8px works for captions and 10.24px for legal text, though 10px is the smallest size many readers can comfortably read.
The CSS uses rem. At a 16px root, 20px is 1.25rem and 48.83px is 3.0518rem. Writing the scale in rem means a reader who sets a larger default font size gets every step larger by the same factor, so the hierarchy stays intact. Switch the output to px only when the scale is for something that must not follow the reader setting, such as a fixed-size social image.
The ratio sets the character of the page. At 1.125 the steps are close together, which suits a dashboard full of labels where headings should not shout. At 1.5 each step is half as big again as the last, which suits a landing page with one large headline. The golden ratio, 1.618, makes the jump from body to heading dramatic: three steps up from 16px is already 67.8px. Try the sample text in the preview with your own words, because a long heading word changes how big a size feels.
The scale has limits. It is one fixed set of sizes; on a phone the top step may be too large, and the scale does not shrink it for you. Use the CSS clamp() Generator for that. It sets font sizes only, not line height, letter spacing or weight, which matter as much for how a heading reads. And a strict ratio is a starting point, not a rule: designers often nudge a step or skip one, as the blog example above does.