Modular Type Scale
Pick a ratio and base size and see four heading sizes grow by the same multiplier each step.
AI prompt
Typographic specimen poster on a warm off-white background showing a modular type scale: four lines of the word Hierarchy in the same sans-serif at ratio 1.25 sizes of 16, 20, 25 and 31 pixels aligned to the left, each line labelled with its pixel size in small grey monospace text on the right, thin hairlines between lines, generous margins, flat, minimal. Variants: ratio 1.618 with much larger jumps. Negative: decorative fonts, mixed typefaces, shadows, gradients, text errors. Reduced motion: static poster.About this pattern
Definition
A modular type scale multiplies a base font size by a fixed ratio to get each next size. Because every step relates to the same number, headings look deliberately related instead of picked one by one.
When to use it
- Small ratios (1.2) feel calm and dense, suited to apps; large ratios (1.618) feel dramatic, suited to editorial pages.
- Choose the body size first, usually 16px, then build upward.
- Round to whole pixels in production, and cap the biggest step on small screens.
What the controls do
- Four ratios and a Base size slider.
Motion & timing
- Sizes update instantly; there is no animation.
- Reduced motion: nothing to change.
Tips & variations
- On mobile, drop one ratio step or use a smaller ratio so headings do not break lines.
- Keep at least 4px difference between neighbouring steps.
Code of this live preview
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Ratio"><button data-p="0" aria-pressed="false">Minor third 1.2</button><button data-p="1" aria-pressed="true">Major third 1.25</button><button data-p="2" aria-pressed="false">Fourth 1.333</button><button data-p="3" aria-pressed="false">Golden 1.618</button></div><label class="rw">Base size <b id="bv">16px</b><input id="bs" type="range" min="12" max="20" value="16"></label><div class="ts" id="ts"></div></div>:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.ts{display:grid;gap:0;border-top:1px solid var(--line)}.ts div{display:flex;justify-content:space-between;align-items:baseline;border-bottom:1px solid var(--line);padding:2px 0;overflow:hidden;white-space:nowrap}.ts span{font-family:ui-monospace,Menlo,monospace;font-size:10.5px;color:var(--muted);flex:none;margin-left:8px}.ts b{font-weight:700;letter-spacing:-.02em;line-height:1.15}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const R=[1.2,1.25,1.333,1.618],ts=document.getElementById('ts'),bs=document.getElementById('bs'),bt=[...document.querySelectorAll('#pre button')];let p=1;
function up(){const b=+bs.value,r=R[p];ts.innerHTML='';[['Heading',2],['Subheading',1],['Body text',0],['Caption',-1]].forEach(([n,k])=>{const s=Math.round(b*Math.pow(r,k)*10)/10,d=document.createElement('div');d.innerHTML='<b style="font-size:'+s+'px">'+n+'</b><span>'+s+'px</span>';ts.appendChild(d);});document.getElementById('bv').textContent=b+'px';bt.forEach(x=>x.setAttribute('aria-pressed',String(+x.dataset.p===p)));}
bt.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;up();}));bs.addEventListener('input',up);up();One complete HTML file. Save it and open it in a browser.
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Modular Type Scale — demo</title>
<style>
:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
html,body{height:100%}body{background:var(--bg);color:var(--text);font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Inter,Roboto,sans-serif;-webkit-font-smoothing:antialiased}.stage{min-height:100%;display:grid;place-items:center;padding:24px}button,input,select,textarea{font-family:inherit}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.ts{display:grid;gap:0;border-top:1px solid var(--line)}.ts div{display:flex;justify-content:space-between;align-items:baseline;border-bottom:1px solid var(--line);padding:2px 0;overflow:hidden;white-space:nowrap}.ts span{font-family:ui-monospace,Menlo,monospace;font-size:10.5px;color:var(--muted);flex:none;margin-left:8px}.ts b{font-weight:700;letter-spacing:-.02em;line-height:1.15}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Ratio"><button data-p="0" aria-pressed="false">Minor third 1.2</button><button data-p="1" aria-pressed="true">Major third 1.25</button><button data-p="2" aria-pressed="false">Fourth 1.333</button><button data-p="3" aria-pressed="false">Golden 1.618</button></div><label class="rw">Base size <b id="bv">16px</b><input id="bs" type="range" min="12" max="20" value="16"></label><div class="ts" id="ts"></div></div>
</div>
<script>
const R=[1.2,1.25,1.333,1.618],ts=document.getElementById('ts'),bs=document.getElementById('bs'),bt=[...document.querySelectorAll('#pre button')];let p=1;
function up(){const b=+bs.value,r=R[p];ts.innerHTML='';[['Heading',2],['Subheading',1],['Body text',0],['Caption',-1]].forEach(([n,k])=>{const s=Math.round(b*Math.pow(r,k)*10)/10,d=document.createElement('div');d.innerHTML='<b style="font-size:'+s+'px">'+n+'</b><span>'+s+'px</span>';ts.appendChild(d);});document.getElementById('bv').textContent=b+'px';bt.forEach(x=>x.setAttribute('aria-pressed',String(+x.dataset.p===p)));}
bt.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;up();}));bs.addEventListener('input',up);up();
</script>
</body></html>