Build a modular type scale (major third, perfect fourth, etc) with code export.
Real hierarchy using your scale. Largest → h1, base → body, smallest → caption.
:root {
--text--3: 8.19px;
--text--2: 10.24px;
--text--1: 12.8px;
--text-base: 16px;
--text-1: 20px;
--text-2: 25px;
--text-3: 31.25px;
--text-4: 39.06px;
}
/* Usage */
.text--3 { font-size: 8.19px; }
.text--2 { font-size: 10.24px; }
.text--1 { font-size: 12.8px; }
.text-base { font-size: 16px; }
.text-1 { font-size: 20px; }
.text-2 { font-size: 25px; }
.text-3 { font-size: 31.25px; }
.text-4 { font-size: 39.06px; }A modular typography scale is a set of font sizes derived from a base size using a fixed ratio. Each step is the previous size multiplied by that ratio. Consistent ratios matter because they create visual harmony: random font sizes (12px, 18px, 23px, 31px) feel arbitrary; a 1.25 scale (12.8, 16, 20, 25) feels intentional. Random sizes fail at scale because you end up with dozens of one-off values that don't relate to each other. A scale gives you a system.
Minor Second (1.067) and Minor Third (1.2) produce subtle steps — good for dense UIs, dashboards, and data-heavy applications where you need hierarchy without dramatic jumps. Major Third (1.25) is the common web default: enough contrast for headings vs body, not too dramatic. Perfect Fourth (1.333) and Golden Ratio (1.618) create stronger contrast — ideal for editorial, marketing, and landing pages where you want punch. Pick based on density: tighter UIs need smaller ratios; marketing and editorial can go bigger.
Scales pair well with CSS variables because you define the scale once and reference it everywhere: font-size: var(--text-2). That becomes a design token — a named value in your system. Typography scales improve consistency across components because every heading, body, and caption pulls from the same source. No more font-size: 17px in one place and 18px in another. The Spacing Scale Assistant applies the same principle to layout spacing.
rem is usually better for accessibility: it respects the user's default font size and browser zoom. Users who set a larger base font get proportionally larger type. px ignores user preferences and can lock text at a fixed size. When to use px: when you need pixel-perfect alignment with fixed assets, or in rare cases where rem causes layout issues. For typography, default to rem. Your base (e.g. 16px) maps to 1rem; scale steps become 1.25rem, 1.56rem, etc. Users who zoom or change font size get a better experience.
Static scales give you fixed sizes at each step. Fluid typography uses clamp() to smoothly scale between a minimum and maximum based on viewport width. Use a static scale when your layout is responsive via breakpoints and you want predictable sizes. Use fluid type when you want type to grow smoothly with the viewport (e.g. hero headlines). The CSS Clamp Calculator helps you generate fluid values; you can combine it with scale steps as min/max boundaries.
A modular type scale uses a fixed ratio (e.g. 1.25 for Major Third) to generate a set of font sizes from a base size. Each step is the previous size multiplied by the ratio, giving consistent, harmonious typography.
Major Second (1.125) and Minor Third (1.2) are subtle; Major Third (1.25) and Perfect Fourth (1.333) are common for UI. Perfect Fourth and Golden Ratio (1.618) create more dramatic contrast. Pick based on how much size contrast you want.
rem is preferred for accessibility (respects user font-size). Use px if you need pixel-perfect control. The generator outputs in your chosen unit; you can also use the clamp calculator for fluid typography between scale steps.
Explore these related free tools to enhance your productivity and workflow.
Generate responsive clamp() values for font size and spacing
Generate CSS box shadows with custom offsets, blur, spread, color, and opacity
Create beautiful linear and radial CSS gradients with custom colors, angles, and stops
Create custom border radius values for all corners with individual or locked controls