CSS Generator

CSS clamp() & Fluid Typography Calculator

Generate responsive, fluid font sizes that scale smoothly between two viewports with one line of clamp(). Drag the live graph, preview real text, build a whole modular type scale, then copy clean CSS, custom properties or Tailwind.

Font-size vs. viewport width 768px vw 20.0px
viewport width (px) font-size (px)

Drag anywhere on the graph to scrub the viewport ✦

Live preview
768px 20.0px
Heading · 768px

Fluid typography scales beautifully

Resize the viewport and watch this text grow and shrink smoothly between your minimum and maximum sizes — no media queries, just one clamp().

clamp() works in all modern browsers

The free CSS clamp() & fluid typography calculator

This fluid typography calculator turns two font sizes and two viewport widths into a single, responsive font-size: clamp() declaration that scales text smoothly between phones and large desktops — no media queries required. Set your minimum and maximum size, choose where the scaling starts and stops, watch the interactive graph and live preview update instantly, then copy production-ready CSS, CSS custom properties or Tailwind. You can even generate an entire fluid modular type scale in one click. Free, no sign-up, no watermark.

What is fluid typography?

Fluid typography is type that scales continuously with the size of the screen instead of jumping at fixed breakpoints. Rather than declaring font-size: 16px on mobile and font-size: 24px on desktop via media queries, fluid type interpolates every size in between, so your headings and body copy always feel proportional to the viewport. The modern way to do this is a single line of CSS using clamp() with a vw-based preferred value.

How does CSS clamp() work?

The clamp() function takes three arguments — clamp(MIN, PREFERRED, MAX) — and returns the preferred value, but never lets it drop below the minimum or rise above the maximum. For fluid type, the minimum is your small-screen size, the maximum is your large-screen size, and the preferred value is a calc() expression mixing rem and vw so the size grows linearly with the viewport. Below the min viewport the text stays flat at the minimum; above the max viewport it stays flat at the maximum; in between it scales — exactly the three segments you see plotted on the graph above.

The fluid typography formula explained

Given a minimum font size, a maximum font size and the two viewport widths between which scaling should happen, the calculator works out the line that connects the two “knee” points:

  1. Slope = (maxFont − minFont) ÷ (maxViewport − minViewport).
  2. Y-axis intersection = −minViewport × slope + minFont (the value the line would hit at a 0px viewport).
  3. Preferred = (yAxisIntersection)rem + (slope × 100)vw.
  4. Result = clamp(minRem, preferred, maxRem).

For the defaults (16px → 24px between 320px and 1280px viewports) that produces font-size: clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem). The rem part anchors the size to the user's root font size and the vw part adds the responsive growth.

Why use rem and vw together

Using vw alone for font-size is an accessibility trap: it ignores the user's browser zoom and root font-size preferences, so text can't be resized. Pairing a rem term with the vw term keeps the type responsive and respects user settings, because the rem portion still scales when someone increases their base font size. That's why this generator always outputs a rem + vw preferred value and offers a rem-based clamp() by default, with a px option when you need it.

Features of this fluid type generator

  • Interactive graph — drag to scrub the viewport and watch the clamped curve, knee points and live font-size readout.
  • Live preview — real heading and paragraph text rendered at the computed size for any simulated viewport width.
  • Type scale mode — generate fluid clamp() values for a whole modular scale as --step-* custom properties.
  • rem or px output — accessible rem by default, with a configurable root font size for conversion.
  • One-click presets — Body, H1, Hero and Caption pairs to start from.
  • Export anywhere — copy as CSS, :root custom properties or Tailwind arbitrary values.

Browser support for clamp()

CSS clamp(), min() and max() are supported in every modern browser — Chrome, Edge, Firefox and Safari — and have been for years, so you can ship fluid typography to production with confidence. For very old browsers you can wrap a fixed fallback in an @supports (font-size: clamp(1rem, 1vw, 2rem)) query, but in practice a plain fixed font-size before the clamped one is enough as a graceful fallback.

CSS clamp() & fluid typography — frequently asked questions

Is this fluid typography calculator free to use?

Yes. The calculator is 100% free with no sign-up, no watermark and no limits. Generate as many fluid clamp() values and type scales as you like and copy the CSS straight into your project.

What is the formula behind fluid typography with clamp()?

The slope is (maxFont − minFont) ÷ (maxViewport − minViewport). The preferred value is (−minViewport × slope + minFont)rem + (slope × 100)vw, wrapped as clamp(minRem, preferred, maxRem). This calculator does all the maths and rounding for you.

Should I use rem or px for clamp() font sizes?

Use rem. A rem-based clamp() respects the user's root font-size and browser zoom, which is important for accessibility, while the vw term still provides the responsive scaling. This tool outputs rem by default and lets you set the root size used for conversion.

Why combine vw with rem instead of using vw alone?

Font sizes set purely in vw can't be resized by the user and ignore zoom, which fails accessibility guidelines. Adding a rem term keeps the type both fluid and user-resizable, so combining the two is the recommended approach.

Do all browsers support CSS clamp()?

Yes. clamp() is supported in all current versions of Chrome, Edge, Firefox and Safari and has been widely available for years. For legacy browsers, declare a fixed font-size first as a fallback, then the clamped value.