Type Hierarchy Before and After
The same article snippet before and after fixing size, weight, spacing and colour, with the changes listed.
AI prompt
Clean side-by-side comparison of one article card typeset badly and well: on the left Before, all text in the same medium grey at the same size with tight spacing so the title, author line and body blend together, on the right After, a bold large dark title, small muted uppercase category label above it, a smaller grey byline, comfortable body text with generous line height and spacing between groups, light theme, flat modern style, small annotations pointing to the changes. Negative: decorative fonts, clutter, text errors. Reduced motion: static design.About this pattern
Definition
Hierarchy tells readers what matters first. When everything has the same size and weight, nothing stands out and reading feels like work. A few controlled changes make the structure visible: a clear size step for the title, weight and colour for labels, space between groups, and a comfortable line length.
When to use it
- Title: larger and heavier; body: regular, 16 px, line height 1.5; meta: smaller and muted.
- Add more space between groups than inside groups.
- Limit to one or two typefaces and a few weights.
- Keep line length around 45 to 75 characters.
What the controls do
- Toggle Before and After; the change list highlights what was fixed.
Motion & timing
- The change fades over 200ms.
- Reduced motion: no fade.
Tips & variations
- Do not rely on size alone; weight, colour and spacing carry hierarchy too.
- Check contrast of muted text.
Code of this live preview
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Version"><button data-p="0" aria-pressed="true">Before</button><button data-p="1" aria-pressed="false">After</button></div><article class="ar" id="ar"><span class="ct">Travel</span><h4>Three quiet towns to visit this autumn</h4><p class="by">By Maria Costa · 6 min read</p><p class="bd">Crowds thin out after the summer, prices drop and the light turns golden. These small towns are easy to reach by train and best explored on foot over a long weekend.</p></article><ul class="chg" id="chg"></ul></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}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}a{color:inherit;text-decoration:none}ul,ol,p,h4{margin:0;padding:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.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}
.ar{border:1px solid var(--line);border-radius:12px;padding:12px;background:#fff;font-family:system-ui,sans-serif;transition:opacity .2s}.ar .ct{font-size:12px;color:#777}.ar h4{font-size:13px;font-weight:400;color:#777;margin:0}.ar .by{font-size:13px;color:#777;margin:0}.ar .bd{font-size:13px;color:#777;margin:0;line-height:1.15}.ar.af .ct{display:block;font-size:10.5px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:#d1432f;margin-bottom:4px}.ar.af h4{font-size:19px;line-height:1.2;font-weight:800;color:#141414;margin:0 0 4px}.ar.af .by{font-size:11.5px;color:#6a6a6a;margin-bottom:10px}.ar.af .bd{font-size:13px;color:#2b2b2b;line-height:1.55}.chg{list-style:none;display:grid;gap:2px;font-size:11.5px;color:var(--muted);margin-top:6px}.chg li::before{content:"\2022 "}@media (prefers-reduced-motion:reduce){.ar{transition:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const ar=document.getElementById('ar'),chg=document.getElementById('chg'),bs=[...document.querySelectorAll('#pre button')];let p=0;
function up(){ar.classList.toggle('af',p===1);chg.innerHTML=p===0?'<li>Everything is the same size and grey.</li><li>No space between title, byline and text.</li><li>Tight line height makes the paragraph dense.</li>':'<li>Title is larger, heavier and darker.</li><li>Category label is small, uppercase and accented.</li><li>Byline is smaller; body has 1.55 line height.</li><li>More space between groups than inside them.</li>';bs.forEach(b=>b.setAttribute('aria-pressed',String(+b.dataset.p===p)));}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;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>Type Hierarchy Before and After — 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}}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}a{color:inherit;text-decoration:none}ul,ol,p,h4{margin:0;padding:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.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}
.ar{border:1px solid var(--line);border-radius:12px;padding:12px;background:#fff;font-family:system-ui,sans-serif;transition:opacity .2s}.ar .ct{font-size:12px;color:#777}.ar h4{font-size:13px;font-weight:400;color:#777;margin:0}.ar .by{font-size:13px;color:#777;margin:0}.ar .bd{font-size:13px;color:#777;margin:0;line-height:1.15}.ar.af .ct{display:block;font-size:10.5px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:#d1432f;margin-bottom:4px}.ar.af h4{font-size:19px;line-height:1.2;font-weight:800;color:#141414;margin:0 0 4px}.ar.af .by{font-size:11.5px;color:#6a6a6a;margin-bottom:10px}.ar.af .bd{font-size:13px;color:#2b2b2b;line-height:1.55}.chg{list-style:none;display:grid;gap:2px;font-size:11.5px;color:var(--muted);margin-top:6px}.chg li::before{content:"\2022 "}@media (prefers-reduced-motion:reduce){.ar{transition:none}}
@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="Version"><button data-p="0" aria-pressed="true">Before</button><button data-p="1" aria-pressed="false">After</button></div><article class="ar" id="ar"><span class="ct">Travel</span><h4>Three quiet towns to visit this autumn</h4><p class="by">By Maria Costa · 6 min read</p><p class="bd">Crowds thin out after the summer, prices drop and the light turns golden. These small towns are easy to reach by train and best explored on foot over a long weekend.</p></article><ul class="chg" id="chg"></ul></div>
</div>
<script>
const ar=document.getElementById('ar'),chg=document.getElementById('chg'),bs=[...document.querySelectorAll('#pre button')];let p=0;
function up(){ar.classList.toggle('af',p===1);chg.innerHTML=p===0?'<li>Everything is the same size and grey.</li><li>No space between title, byline and text.</li><li>Tight line height makes the paragraph dense.</li>':'<li>Title is larger, heavier and darker.</li><li>Category label is small, uppercase and accented.</li><li>Byline is smaller; body has 1.55 line height.</li><li>More space between groups than inside them.</li>';bs.forEach(b=>b.setAttribute('aria-pressed',String(+b.dataset.p===p)));}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;up();}));up();
</script>
</body></html>