Enter your minimum and maximum sizes plus the viewport range, get a fluid clamp() formula with the full math shown, and watch the demo text scale live.
What is the CSS Clamp() Calculator?
A CSS clamp() calculator generates fluid sizing formulas that scale smoothly between breakpoints. The clamp(MIN, PREFERRED, MAX) function picks a preferred value but never lets it drop below MIN or rise above MAX — and when the preferred value mixes fixed pixels with viewport units (vw), you get typography and spacing that grow fluidly as the screen widens, with no media queries at all.
The math behind the preferred value is a straight line between two points: your minimum size at the small viewport and your maximum size at the large viewport. The calculator works out the slope and intercept of that line and expresses it as Xpx + Yvw. Getting this arithmetic right by hand is fiddly; one transposed digit and your type scales backwards. This tool does the algebra for you and shows every step so you can verify it.
Fluid type with clamp() has become the professional standard for responsive typography: one declaration replaces three or four media-query font sizes, headings scale gracefully on every screen in between, and the MIN/MAX guards keep text readable on watches and ultrawides alike. The same technique works for spacing, container widths and any length that should breathe with the viewport.
How to use the CSS Clamp() Calculator
- Enter your <strong>minimum size</strong> — the smallest the value should ever be, in pixels.
- Enter your <strong>maximum size</strong> — the largest it should ever reach.
- Set the <strong>viewport range</strong>: the small screen width where scaling starts and the large width where it stops.
- Read the <strong>math breakdown</strong> to see the slope and intercept behind your formula.
- Resize your browser window and watch the <strong>demo text</strong> scale fluidly between your min and max.
- Copy the <code>clamp()</code> declaration into your stylesheet.
CSS Clamp() Calculator use cases
Fluid responsive headings
A hero heading that is 32px on phones and 64px on desktops, scaling smoothly through every tablet size in between — one clamp() line replaces a stack of media queries and never jumps at breakpoints.
Body text that stays readable
Paragraph text clamped between 16px and 18px grows just enough on large screens to stay comfortable without ever becoming oversized or microscopic. Readers get an optimal measure on every device automatically.
Fluid spacing and padding
Section padding that breathes with the viewport — tight on mobile, generous on desktop — keeps proportions consistent without breakpoint-specific spacing rules. One declaration replaces a whole stack of media queries.
Responsive component sizing
Buttons, badges and cards can use clamp() for padding, font-size and border-radius so entire components scale as one harmonious system. Components then feel proportional on phones and desktops alike.
Container widths
Content wrappers clamped between a mobile minimum and a desktop maximum stay readable on ultrawide monitors while using small screens fully. No more unreadably long lines on huge widescreen displays.
Tips
- Keep the viewport range realistic — 360px to 1200px covers phones through laptops for most sites.
- The MIN and MAX guards are the safety net: below and above your range, the size locks instead of shrinking or growing forever.
- Use the same viewport range across your site so all fluid values scale in sync.
- Prefer modest ratios (1.5x–2x between min and max) — extreme scaling looks unstable.
- Clamp works for any CSS length: font-size, padding, margin, gap, width and border-radius all accept it.