← back to flaviocopes.com

CSS clamp() calculator

← All tools

Enter min and max font sizes plus the viewport range where they should apply. Get a ready-to-paste clamp() in rem and vw, with the slope math spelled out.

~~~

Inputs

~~~

Result

~~~

Live preview

Drag the slider to simulate viewport width. Preview font size:

Viewport:

The quick brown fox jumps over the lazy dog.

Everything runs in your browser. The formula linearly interpolates between your min and max font sizes across the viewport range, thenclamp() caps the result.

~~~

About this tool

Fluid typography scales font size between a minimum and maximum based on viewport width. CSS clamp() is the one-liner that does it: a minimum, a preferred value (usually rem + vw), and a maximum.

This calculator converts your pixel inputs into rem and vw using your root font size, so you can drop the result straight into a stylesheet. The slope is (max − min) / (maxVw − minVw); the intercept anchors the line at your min viewport.

~~~

Read more