Skip to content

CSS Clamp Calculator

Calculate a CSS clamp() value for fluid font sizes and spacing. Enter the smallest and largest size in pixels and the viewport widths where each should apply, and the tool works out the linear formula in rem or px plus vw, with the bounds that stop it from growing or shrinking further. A table shows the size at common screen widths.

Reset

Frequently asked questions

How is the clamp() value calculated?

The tool draws a straight line between your minimum size at the minimum viewport width and your maximum size at the maximum viewport width. The slope becomes the vw part, the starting offset becomes the rem or px part, and the two sizes become the lower and upper bounds of clamp().

Why use rem instead of px?

rem values scale with the browser's font size setting, so text stays readable for people who increase their default size. The tool divides pixel values by the root font size, which is 16 pixels in every major browser unless the page or the user changes it.

What happens outside the viewport range?

Below the minimum viewport width the value stays at the minimum size, and above the maximum width it stays at the maximum size, because clamp() returns its lower or upper bound when the middle value passes them.

Can the size shrink as the screen grows?

Yes. Enter a minimum size larger than the maximum size and the vw part becomes negative. The bounds are still ordered from small to large, as clamp() requires.

Does a fluid font size affect accessibility?

It can. A size that depends mostly on vw does not grow when people zoom, which WCAG 1.4.4 asks for. Keeping a rem part in the formula and a moderate range between the two sizes keeps zoom working.

Where can I use the result?

Anywhere CSS accepts a length, such as font-size, padding, margin, gap or width. clamp() works in all current browsers.

About OneClick Pro

OneClick Pro is a free collection of more than 150 web tools for everyday work: converting images and units, formatting and validating code, checking domains and SEO, and working with text, dates and numbers. Every tool runs without registration or subscription, and what you enter is only used to calculate your result and is never stored. Use it as a quick toolbox for one-off tasks, or bookmark the tools you rely on every day.