thoughtasylumTOOLBOX Preview Guides Use offline Automate Feedback

Tools › Fonts

Type Scale

Font sizes for headings and text that grow by a steady ratio from a base size, shown in a sample and written as CSS custom properties in rem, or as fluid clamp() sizes that grow with the screen. Also converts CSS units (px, rem, em, pt, vw, vh) and builds a clamp() from two sizes.

About this tool What it's for, how to use it and an example

What it's for

Pick a set of font sizes that look right together. A type scale starts from a base size, usually body text, and multiplies it by the same ratio for each step up (headings) and divides for each step down (small print). This shows the sizes, a sample in each, and the CSS to use them. Two smaller tools sit beside it: one converts a CSS length between px, pt, rem, em, vw and vh, and one builds a fluid clamp() size from a smallest and a largest size.

For example, when you’re setting heading sizes for a website, try a few ratios here, see which looks right, and copy the CSS custom properties into your stylesheet.

How to use it

Set the Base size in pixels and choose a Ratio, or Another to type your own. Choose how many Steps above the base and below you want, the Name prefix for the CSS custom properties, and the Sample text. The base size and ratio are remembered in this browser.

The table lists each size in pixels, as CSS in rem (a base of 16 pixels to the rem), and in a sample. The CSS box has them all as custom properties, such as --step-1, with --step-n1 for the steps below the base.

Tick Fluid for sizes that grow with the screen: give the narrowest and widest screen widths, and the base size (and, if you like, a different ratio) to use on the widest. Each size becomes a CSS clamp() that grows smoothly from its size on the narrowest screen to its size on the widest.

CSS units converts a Value in px, pt, rem, em, vw or vh to every other unit. The Root font size (16 pixels by default) is what rem and em are measured against, and the Viewport width and height are what vw and vh are measured against. em is worked out as if the element sits directly under the root.

Fluid clamp() builds the clamp() on its own: the size on the narrowest screen and the size on the widest, each in px or rem, and the two screen widths. The CSS is clamp(smallest, intercept + slope, largest) in rem, ready to copy. The rem sizes use the root font size from CSS units.

Example

With the defaults (a base of 16 pixels and a ratio of 1.25, a major third), the sizes run from 48.83 pixels at --step-5 down to 10.24 at --step-n2, and the CSS starts:

:root {
  --step-5: 3.0518rem;
  --step-4: 2.4414rem;
  --step-3: 1.9531rem;

For the fluid clamp, with the sizes in px, enter 16 for the size on the narrowest screen and 24 for the widest, with screens of 320 and 1280 pixels. The CSS is:

clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem)

Good to know

The rem sizes assume the browser’s default of 16 pixels to the rem; a visitor who has made their default text bigger gets bigger sizes too, which is the point of using rem. The sizes are worked out to four decimal places, and browsers round them when drawing.

A fluid clamp() is a straight line between its two sizes: it holds the size on the narrowest screen below that width and the size on the widest above it. The units converter takes em as the root size, so an em inside a nested element will differ.

Guides: Making a page look finished with CSS · Getting a font ready for the web

NameSizeCSSSample

CSS units

UnitValue

Fluid clamp()

Built with The third-party code and data this tool uses, and their licences

This tool uses no third-party code or data of its own: its code was written for this site.

Every page also uses Montserrat (SIL Open Font License 1.1).
Everything the site uses is on Credits and licences.

Private: this tool runs in your browser. Nothing you type, paste or choose leaves this page.

Saved you a few minutes? Say thanks with a coffee.

Something wrong with this tool, or missing from it? Report a bug or suggest a feature.

↑ ↓ move↵ openesc close