Typography Scale Generator

Calculate harmonious modular type scales and responsive rem/px font scaling ratios (Golden Ratio, Perfect Fourth, Major Third) for web UI design.

Live Type Scale Hierarchy16px × 1.25ⁿ
h1×1.255
3.052rem48.83px
The quick brown fox
h2×1.254
2.441rem39.06px
The quick brown fox
h3×1.253
1.953rem31.25px
The quick brown fox
h4×1.252
1.563rem25.00px
The quick brown fox
h5×1.251
1.250rem20.00px
The quick brown fox
h6×1.250
1.000rem16.00px
The quick brown fox
p (Base)
1.000rem16.00px
The quick brown fox jumps over the lazy dog.

The Mathematical Theory of Modular Scales

A modular typographic scale is a geometrically ordered sequence of proportional font sizes governed by a fixed multiplication ratio. Rather than selecting arbitrary, disconnected pixel values for headings, body copy, and captions (e.g., 14px, 19px, 31px), a modular scale applies the principles of classical harmonics to create visual resonance, predictable visual hierarchy, and structural consistency across an interface.

The mathematical formula generating each scale step is a geometric sequence:

Sn = Base × rn

Where Base represents your root reading size (typically 1rem or 16px), r is the common musical ratio (such as 1.250 for Major Third or 1.333 for Perfect Fourth), and n is an integer step index:

  • n = 0: Base body typography (e.g., 16 × r0 = 16px)
  • n > 0: Ascending headings (H4, H3, H2, H1, Display)
  • n < 0: Descending auxiliary text (small labels, footnotes, code badges, captions)

Classical Musical Ratios & Application Matrix

Typographic scale ratios originate in the acoustic intervals of musical tuning systems. Each ratio communicates a distinct emotional tone and suits specific interface information densities:

Musical IntervalRatio (r)Visual CharacterRecommended Use Case
Minor Second1.067 (15:16)Ultra-compact, subtle differentiationFinancial trading terminals, complex spreadsheets, data-dense enterprise tables
Major Second1.125 (8:9)Compact, orderly hierarchyB2B SaaS dashboards, developer documentation, settings panels
Minor Third1.200 (5:6)Balanced, comfortable pacingE-commerce storefronts, mobile application interfaces, user account portals
Major Third1.250 (4:5)Clear contrast, modern rhythmTechnology blogs, corporate marketing websites, product landing pages
Perfect Fourth1.333 (3:4)Bold, commanding hierarchyLong-form editorial journalism, digital magazines, agency case studies
Augmented Fourth1.414 (√2)Dramatic, striking presenceHigh-impact marketing hero sections, creative portfolios, event keynotes
Golden Ratio (φ)1.618 (1:φ)Monumental, expansive contrastLuxury brand showrooms, editorial posters, museum exhibition sites

Vertical Rhythm, Line Heights & Baseline Alignment

Scale alone cannot guarantee typographic harmony. You must also calibrate line-height (leading) across scale steps.

The Inverse Leading Law

A frequent design error is applying a static line-height (such as line-height: 1.5) across all typographic tiers. The physics of ocular reading dictates an inverse relationship between font size and line height:

  • Body Text (14px–18px): Requires generous breathing space (line-height: 1.5 to 1.7) to allow the reader's eye to travel comfortably back to the left margin without jumping lines.
  • Display Headings (32px–72px+): Must have tight leading (line-height: 1.05 to 1.2). When large headings span multiple lines with loose leading, the massive whitespace creates awkward gaps that disrupt syntactic grouping.

Snapping to an 8px Baseline Grid

To prevent layout jitter and misaligned UI components, professional design systems align all font sizes and line-heights to an 8px (or 4px sub-grid) baseline. For instance, a 16px body font with line-height: 24px occupies exactly 3 grid rows (3 × 8px), and a 32px heading with line-height: 40px occupies exactly 5 grid rows.

Fluid Typography Mathematics & The clamp() Function

Instead of abrupt, jagged font jumps across CSS media query breakpoints (such as resizing H1 from 32px to 48px at 768px screen width), modern responsive design employs fluid typography using the CSSclamp() function:

/* Mathematical fluid clamp formula */
font-size: clamp(min-size, preferred-linear-scale, max-size);

Deriving the Slope & Intercept

To interpolate seamlessly between a minimum font size y1 at viewport width x1 and a maximum font size y2 at viewport widthx2, calculate the linear equation parameters:

Slope (m) = (y2 - y1) / (x2 - x1)

Viewport Unit = Slope × 100vw

Intercept (b) = y1 - (Slope × x1)

/* Smooth fluid H1 scaling from 32px (at 375px viewport) to 56px (at 1280px viewport) */
h1 {
  font-size: clamp(2rem, 1.378rem + 2.65vw, 3.5rem);
}

Typography Accessibility Standards (WCAG 2.1 & 2.2)

When implementing your typography tokens in production code, adhering to Web Content Accessibility Guidelines (WCAG) is essential:

  • Always Export in rem, Never Hardcode px: Hardcoding font sizes in px prevents browser font zoom from taking effect for users with low vision. According to WCAG 2.1 Success Criterion 1.4.4 (Resize Text), interfaces must scale text up to 200% without breaking page layouts. Sizing in root-relative rem (where 1rem = 16px by default) respects user operating system and browser preferences.
  • WCAG 1.4.12 (Text Spacing Compliance): Users must be able to adjust line-height to at least 1.5, letter-spacing to at least 0.12em, and word-spacing to at least 0.16em without text being cut off by hardcoded container heights (height or overflow: hidden).
  • The Reading Measure: Keep body paragraph measure between 45 and 75 characters per line (typically max-width: 65ch in CSS). Exceeding 80 characters forces excessive ocular strain during horizontal line tracking.

Production Architecture: CSS Variables & Design Tokens

To translate your modular scale into maintainable code across large engineering teams, structure your scale steps as CSS Custom Properties in your global design system tokens:

:root {
  /* Base scale parameters (Major Third 1.250) */
  --font-ratio: 1.25;
  --font-base: 1rem; /* 16px */

  /* Computed scale steps */
  --font-size-xs: calc(var(--font-base) / (var(--font-ratio) * var(--font-ratio))); /* 0.64rem / 10.24px */
  --font-size-sm: calc(var(--font-base) / var(--font-ratio));                        /* 0.8rem / 12.8px */
  --font-size-base: var(--font-base);                                                /* 1rem / 16px */
  --font-size-md: calc(var(--font-base) * var(--font-ratio));                        /* 1.25rem / 20px */
  --font-size-lg: calc(var(--font-size-md) * var(--font-ratio));                     /* 1.563rem / 25px */
  --font-size-xl: calc(var(--font-size-lg) * var(--font-ratio));                     /* 1.953rem / 31.25px */
  --font-size-2xl: calc(var(--font-size-xl) * var(--font-ratio));                    /* 2.441rem / 39.06px */
  --font-size-3xl: calc(var(--font-size-2xl) * var(--font-ratio));                   /* 3.052rem / 48.83px */

  /* Calibrated line-heights */
  --line-height-tight: 1.15;
  --line-height-snug: 1.3;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.625;
}

Tailwind CSS Integration Strategy

In modern Tailwind configurations (tailwind.config.js), you can pair font sizes with their corresponding line heights and letter-spacing directly in the scale tuple:

// tailwind.config.js
module.exports = {
  theme: {
    extend: {
      fontSize: {
        'xs': ['0.8rem', { lineHeight: '1.25rem', letterSpacing: '0.02em' }],
        'sm': ['0.889rem', { lineHeight: '1.375rem', letterSpacing: '0.01em' }],
        'base': ['1rem', { lineHeight: '1.5rem', letterSpacing: '0' }],
        'xl': ['1.25rem', { lineHeight: '1.75rem', letterSpacing: '-0.01em' }],
        '2xl': ['1.563rem', { lineHeight: '2rem', letterSpacing: '-0.02em' }],
        '3xl': ['1.953rem', { lineHeight: '2.25rem', letterSpacing: '-0.02em' }],
        '4xl': ['2.441rem', { lineHeight: '2.75rem', letterSpacing: '-0.03em' }],
      },
    },
  },
};

Font Pairing & Optical x-Height Calibration

Matching x-Heights Across Typefaces

When pairing distinct font families (e.g., a serif for editorial headlines and a sans-serif for UI labels and body paragraphs), font size alone does not determine visual harmony. Different typefaces rendered at the exact same font-size: 16px will appear radically different in visual weight due to their x-height (the height of the lowercase letter "x" relative to the uppercase cap height).

A typeface with a tall x-height (like Inter or Roboto) looks significantly larger and denser than a typeface with a petite x-height (like Garamond or Futura) at the identical point size. When mixing fonts in the same modular scale:

  • Calibrate with font-size-adjust: The CSS font-size-adjust property preserves perceived size across primary fonts and fallback stacks by normalizing the aspect value (x-height divided by font size).
  • Rule of Distinct Roles: Never pair two fonts that look almost identical (such as Helvetica and Arial, or Roboto and Open Sans). Pair typefaces with distinct structural contrasts (e.g., geometric sans-serif with transitional serif, or humanist sans with monospace data fonts).

Practical Real-World Use Cases

  • Establish a website heading hierarchy: Generate a proportional progression from base body copy (1rem) up through H6 to H1 display headings using a mathematical ratio.
  • Standardize SaaS dashboard text sizes: Define clear, predictable sizing steps for data table cells, card titles, section headers, and KPI metrics.
  • Format long-form blog and documentation layouts: Select a harmonious modular scale (such as Major Third or Perfect Fourth) so multi-level article headings feel visually balanced.
  • Plan responsive type scales: Generate a tighter scale for mobile screens and a wider ratio for desktop viewports to keep headings proportional across devices.
  • Eliminate arbitrary font sizes: Replace dozens of ad-hoc pixel values in a legacy stylesheet with a clean, systematic 6-to-8 step type scale.

Zero Server Upload Guarantee

100% Client-side mathematical generation. OmniTools calculates your modular scales, fluid interpolation clamps, and design tokens entirely inside your local web browser.

No font configurations, token names, or branding scales are ever transmitted to or stored on remote servers.

Frequently Asked Questions

What is a modular type scale in web design and CSS?

A modular typography scale multiplies or divides a base font size (typically 16px / 1rem) by a consistent mathematical ratio—such as Major Third (1.250), Perfect Fourth (1.333), Augmented Fourth (1.414), or Golden Ratio (1.618)—to establish harmonious heading and body text hierarchy.

Should I use rem, em, or px for responsive font scaling?

Use rem units (relative to the root html font size) or fluid CSS clamp() expressions so typography scales predictably and respects user browser accessibility zoom preferences.