Skip to content
T
Tools.Town
Free Online Tools for Everyone
Design Tools

Type Scale Generator Guide — Modular Typography Ratios & CSS Output

How to build a modular CSS type scale using classic ratios like Perfect Fourth and Golden Ratio. Outputs CSS custom properties and a Tailwind fontSize config.

25 June 2026 5 min read By Tools.Town Team Fact Checked

Key Takeaways

  • A modular type scale is a set of font sizes derived by multiplying a base size by a ratio repeatedly
  • Perfect Fourth (1
  • The base size is typically 16px (1rem in most browsers)
  • Use rem

What is a modular type scale?

A modular type scale picks a single ratio and multiplies your base font size by it to produce each step upward, and divides to produce each step downward. The result is a harmonious hierarchy where every size relates to every other.

With a base of 16px and a Perfect Fourth ratio (1.333):

StepCalculationSizeName
−216 ÷ 1.333²9.003pxxs
−116 ÷ 1.33312.003pxsm
01616pxbase
+116 × 1.33321.328pxlg
+216 × 1.333²28.430pxxl
+316 × 1.333³37.897px2xl

Choosing a ratio

NameRatioCharacter
Minor Second1.067Very subtle. Good for mono-weight UIs
Major Second1.125Tight. Data tables, dense layouts
Minor Third1.200Comfortable. General purpose
Major Third1.250Slightly dramatic
Perfect Fourth1.333Most popular for web
Augmented Fourth1.414Striking. Good for editorial
Perfect Fifth1.500Bold hierarchy
Golden Ratio1.618Maximum drama. Display/marketing

Start with Perfect Fourth. If you find the contrast between steps too large, go one smaller.

CSS custom properties output

The generator produces a :root { } block:

:root {
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.333rem;
  --font-size-xl: 1.777rem;
  --font-size-2xl: 2.369rem;
}

Reference them anywhere: font-size: var(--font-size-lg).

Tailwind fontSize config

Copy the Tailwind output into your tailwind.config.js under theme.extend.fontSize:

fontSize: {
  "xs": "0.75rem",
  "sm": "0.875rem",
  "base": "1rem",
  "lg": "1.333rem",
  "xl": "1.777rem",
}

This replaces or augments Tailwind’s default text-xs, text-sm, etc. classes with your scale.

Steps up and down

Most body-text UIs need 2–3 steps down (caption, label, small) and 5–6 steps up (body, lead, h4, h3, h2, h1, display). The generator defaults to 2 down / 6 up. Adjust as needed.

rem vs px vs em

  • rem — relative to root font size (recommended). Respects user browser preferences.
  • px — absolute. Ignores user preferences. Avoid for text.
  • em — relative to parent element. Useful for component-scoped typography but can cascade unexpectedly.

Always set root size to match your html { font-size: ... } declaration (default 16px) for the rem conversion to be accurate.

Advertisement

Try Type Scale Generator — Free

Apply what you just learned with our free tool. No sign-up required.

Try Type Scale Generator

Frequently Asked Questions

What is a modular type scale?
A modular type scale is a set of font sizes derived by multiplying a base size by a ratio repeatedly. Each step is ratio × previous step. This creates visual harmony because every size relates mathematically to every other size.
Which ratio should I use?
Perfect Fourth (1.333) is the most popular for web UI — it gives comfortable hierarchy without extremes. Minor Third (1.200) is subtle for dense UIs. Golden Ratio (1.618) creates dramatic display typography. Major Second (1.125) is very tight — good for data-dense applications.
What is the base font size?
The base size is typically 16px (1rem in most browsers). It corresponds to body text. Steps below it are small / caption text; steps above are headings and display text.
Should I use rem or px?
Use rem. It respects the user's browser font size preference, which affects accessibility. 1rem = 16px by default, but scales with user settings. Only use px when you need truly fixed sizes (e.g. UI chrome elements).

Was this guide helpful?

Your feedback helps us improve our content.

Continue Reading

All Design Tools Guides

Get the best Design Tools tips & guides in your inbox

Join 25,000+ users who get our weekly design tools insights.