Rankite
ServicesResultsToolsTeamAboutBlogCareersContactFree SEO Audit
Free tool

CSS Clamp Calculator: Fluid Typography Generator

Enter your minimum and maximum font sizes and viewport widths to get a ready-to-use CSS clamp() declaration, built on the standard linear interpolation formula.

Home / Tools / CSS Clamp Calculator
CSS output
clamp(1rem, 0.714rem + 1.429vw, 2rem)

This scales smoothly from 16px at a 400px viewport to 32px at a 1280px viewport, and holds steady outside that range.

Built by Rankite, the SEO team behind Swordfish AI's +400% revenue and Zluri's +45% organic growth. See the case studies

How the CSS clamp() function works

clamp(MIN, PREFERRED, MAX) is a real CSS function defined in the W3C CSS Values and Units Module Level 4 specification. The browser evaluates the middle, preferred value on every render and uses it as long as it falls between MIN and MAX, but locks to MIN or MAX the moment the preferred value would go outside that range. For font size, this replaces the old approach of jumping between fixed sizes at media query breakpoints with one continuously scaling value.

The linear interpolation formula behind fluid typography

The preferred value in the middle of clamp() is built from a straight line between two points: your minimum font size at your minimum viewport width, and your maximum font size at your maximum viewport width. The slope of that line becomes a vw-based value, and the line's intercept becomes a fixed rem offset, the same linear interpolation method popularized by fluid-type tools like Utopia and widely used in CSS-Tricks' fluid typography guides.

Where else to use clamp() beyond font size

The same formula and the same clamp() function work for any CSS length property, including padding, margin, gap and width. Enter your minimum and maximum spacing values in place of font sizes above to generate a fluid spacing value using the identical interpolation math.

Related articles

FAQ

CSS Clamp Calculator: questions, answered

What does CSS clamp() actually do?
clamp(MIN, PREFERRED, MAX) picks the preferred value but never lets it go below MIN or above MAX, per the CSS Values and Units Module Level 4 spec, so a size can scale fluidly between two breakpoints instead of jumping at fixed media query steps.
How is the "preferred" middle value calculated?
Through standard linear interpolation: work out the slope between your min and max sizes across your min and max viewport widths, then express that slope as a vw unit plus a fixed rem offset, the same method used by fluid-type tools like Utopia.
Why use rem instead of px in the output?
rem values respect a visitor's browser font size setting for accessibility, while a raw px clamp ignores it. This calculator converts using your chosen root font size, 16px by default.
Does clamp() work in every browser?
Yes. clamp() has been supported in all major browsers since 2020 and is safe to use without a fallback for any site targeting current browser versions.
Can I use clamp() for spacing, not just font size?
Yes. The same formula works for any CSS length property such as padding, margin or gap; just enter your min and max spacing values instead of font sizes.

More free tools

Let's grow

Ready to own page one?

Get a free, no-obligation SEO audit and a 30-minute strategy session. We'll show you exactly where the growth is hiding.

Book your free audit Explore services
Get in touch

Tell us about your project

Fill out the form and we'll get back to you within one business day. Prefer email? Write to us directly at contact@rankite.com.

Or copy our email and write to us directly: contact@rankite.com