Calculators · Free CSS tool

CSS Clamp Calculator

Free · no sign-up Live preview · copy or download the CSS

Fluid type without the guesswork: set your smallest and largest font sizes and the viewport range they map to, and get a mathematically correct clamp() — previewed live on a real headline.

Settings

Resize the window — I stay fluid.

Generated CSS — updates live

The CSS you need to build this yourself

Understand the output, not just copy it — these lessons on our learning path teach exactly what this tool automates:

  1. CSS PX to REM ConverterConverters
  2. CSS Aspect Ratio CalculatorCalculators
  3. CSS Font Pairing ToolTypography & Buttons
  4. CSS Text Gradient GeneratorTypography & Buttons
  5. CSS Grid PlaygroundShape & Layout

How it works

Between your two viewport widths, font size should travel a straight line — so the calculator derives that line: slope = (max − min) ÷ (vmax − vmin), expressed as vw, plus a rem intercept so the value lands exactly on your endpoints. clamp() then pins the result inside min and max.

Why rem in the formula: pure-vw type ignores user font-size settings and browser zoom; mixing a rem term keeps fluid type accessible. The output uses rem for both bounds for the same reason.

Run the code — try it yourself

Give the headline a fluid size: clamp(1.5rem, 0.5rem + 4.44vw, 3.5rem) — then drag the preview divider and watch it glide.

exercise.html — editable

Frequently asked questions

Can I use this for spacing, not just fonts?

Absolutely — padding, margins and gaps take clamp() identically. Fluid section spacing is one of its best uses.

My intercept came out negative — is that valid?

Yes. Steep scaling over a narrow range produces a subtraction form (e.g. 5vw − 0.5rem); browsers evaluate it fine.

Do I still need media queries?

Fewer of them — clamp handles the continuous scaling; keep queries for structural changes like layout switches.

Keep going

One correct clamp() replaces three breakpoint overrides and never jumps. The unit theory is in CSS Sizing & Units; the broader fluid toolkit in Responsive CSS Patterns.

CSSmatic is a non-profit project, made by developers for developers.