CSS clamp() fluid typography generator

Generate the CSS clamp() for a text size that grows fluidly between two viewport widths, with a preview, a type scale you can export as CSS variables and an accessibility check.

Your data stays on your computer. Files are processed in your browser and are never uploaded.

Parameters

Unit of the values

You can write the unit in the value (16px, 1.25rem): the one chosen above only applies to numbers without a unit.

Result

font-size: clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem);
Slope
0.8333vw
Intercept
13.3333px (0.8333rem)
Smallest value
16px
Largest value
24px

Preview

At a 640px viewport the size is 18.67px.

Fluid typography adapts to the width of the screen.

Fluid type scale

It starts from the minimum and maximum sizes above (step 0) and multiplies them by the ratio at each step.

VariableMin (px)Max (px)clamp()Preview
--step--211.1115.36clamp(0.6944rem, 0.6059rem + 0.4426vw, 0.96rem)Aa
--step--113.3319.2clamp(0.8333rem, 0.7111rem + 0.6111vw, 1.2rem)Aa
--step-01624clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem)Aa
--step-119.230clamp(1.2rem, 0.975rem + 1.125vw, 1.875rem)Aa
--step-223.0437.5clamp(1.44rem, 1.1387rem + 1.5063vw, 2.3438rem)Aa
--step-327.6546.88clamp(1.728rem, 1.3274rem + 2.0028vw, 2.9297rem)Aa
--step-433.1858.59clamp(2.0736rem, 1.5441rem + 2.6475vw, 3.6621rem)Aa
--step-539.8173.24clamp(2.4883rem, 1.7919rem + 3.4822vw, 4.5776rem)Aa
:root {
  --step--2: clamp(0.6944rem, 0.6059rem + 0.4426vw, 0.96rem);
  --step--1: clamp(0.8333rem, 0.7111rem + 0.6111vw, 1.2rem);
  --step-0: clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem);
  --step-1: clamp(1.2rem, 0.975rem + 1.125vw, 1.875rem);
  --step-2: clamp(1.44rem, 1.1387rem + 1.5063vw, 2.3438rem);
  --step-3: clamp(1.728rem, 1.3274rem + 2.0028vw, 2.9297rem);
  --step-4: clamp(2.0736rem, 1.5441rem + 2.6475vw, 3.6621rem);
  --step-5: clamp(2.4883rem, 1.7919rem + 3.4822vw, 4.5776rem);
}

How it is computed

The slope is (max − min) / (maximum viewport − minimum viewport) and the intercept is min − slope × minimum viewport. The result is clamp(min, intercept + slope vw, max), with lengths in rem so they follow the font size the user chose.

Accessibility

Using rem in the intercept and the limits keeps text zoom working. If the maximum is more than 2.5 times the minimum, the upper limit may prevent reaching the 200% required by WCAG 1.4.4: the tool warns you.

Privacy

The calculation happens in your browser: the values are not sent to any server.

Keyboard shortcuts

In this tool

This tool has no keyboard actions.

Everywhere

Open this panel (outside text fields)
?
Closes panels and menus, never clears data
Esc
Search for a tool
/ or CtrlK

How to use it

  1. Enter the minimum and maximum text size (px or rem) and the viewport widths it should vary between.
  2. Copy the font-size declaration with the clamp() and try the effect with the simulated width slider.
  3. For a complete scale set the ratios and copy the CSS variables for steps -2 to 5.

Frequently asked questions

Why is the result in rem?

The rem follows the font size the user chose in the browser. If the limits were in pixels, someone who set a larger font would not see it change.

What does the WCAG 1.4.4 warning mean?

The criterion requires that text can be enlarged up to 200% without losing content. With browser zoom the viewport in CSS pixels shrinks, so the size drops toward the minimum: if the maximum is over 2.5 times the minimum, the room to enlarge may not be enough. This is a rule of thumb: also test with real zoom.

Which viewport values should I choose?

Usually 320 px (a small phone) for the minimum and between 1200 and 1440 px for the maximum. Outside that range the size stays at the limits.

How do I use the scale?

Paste the variables in :root and use them as font-size: var(--step-0) for body text, var(--step-3) for headings. Step 0 is the size you chose, negative steps are smaller.

Are the values sent to a server?

No: the calculation happens in your browser.

Tool chains

Link several tools into a path: after using a tool, “Send to…” offers the next step first. Saved chains keep only a name and the tools, never your data.

Saved chains

No saved chains.

New chain