Tools

Set a minimum and maximum size and the viewport widths they apply at, and get a CSS clamp() expression that scales smoothly between them with no media queries. The preview shows the result at your current viewport width.

Sizes (px)

Viewports (px)

Output

Preview

Resize the window to watch this scale.

16px at 360px wide, 32px at 1280px wide, and a straight line in between.

CSS

font-size: clamp(1rem, 1.7391vw + 0.6087rem, 2rem);

The middle value is a slope in vw plus an offset, so the size tracks the viewport exactly between your two breakpoints and stops at the limits either side.

Frequently asked questions

How does clamp() work?
clamp(min, preferred, max) returns the preferred value, but never less than min or more than max. With a preferred value in vw plus a rem offset, the result grows linearly with the viewport between the two limits.
Why is there a rem part in the preferred value?
A pure vw value would hit zero at a zero-width viewport. Adding a rem (or px) offset shifts the line so it passes through exactly the sizes you want at your chosen viewports. The rem part also keeps the result scaling when the user changes their font size.
Can I use this for spacing, not just text?
Yes. Fluid padding, margins and gaps work the same way. Many design systems use clamp() for section spacing so it tightens up on phones without breakpoints.

quick question

Was this tool helpful?