Responsive Typography

Learn to create fluid text that scales smoothly between screen sizes using clamp() and viewport units.

Step 1 of 5

Why fixed font sizes fail on mobile

A heading set to font-size: 48px looks great on a desktop monitor with 1200px of width. But on a 375px phone screen, that same 48px heading might take up two or three lines and dominate the viewport, pushing actual content below the fold. The obvious fix — using a media query to set a smaller font size on mobile — works but creates a jarring jump. At 767px the heading is 48px; at 768px it suddenly snaps to 32px. There's no smooth transition.

Viewport units (vw) seem like the answer: font-size: 5vw scales smoothly with the screen. But they have a critical flaw — on very small screens the text becomes microscopic, and on very large screens it becomes comically huge. A 5vw heading is 18.75px on a 375px phone (barely readable) and 96px on a 1920px monitor (absurdly large). You need a way to scale smoothly while setting a minimum and maximum size. That's exactly what clamp() does.

Look at any well-designed website — Apple.com, Stripe.com, or Medium — and resize your browser window slowly. The headings scale smoothly, never too small to read and never too large to look ridiculous. That's fluid typography in action.

Think of it this way: Fixed font sizes are like wearing the same size shoes everywhere — they fit one place but hurt everywhere else. Viewport units are like shoes that grow and shrink with the room — great in theory, but they might become too big in a warehouse or too small in a closet. Clamp() is like shoes with a size range: 'be at least size 8, grow up to size 12, but scale with the room in between.'
Web Standard
WCAG 2.1 Success Criterion 1.4.4 requires that text can be resized up to 200% without loss of content or functionality. Using relative units (rem, em, vw) for font sizes respects user preferences. If you use only px, users who increase their browser's default font size won't see any change.
CSSREAD ONLY
PREVIEW