CSS clamp() Calculator

Generate a CSS clamp() value for fluid typography and spacing. Set two viewport widths and sizes, preview scaling, and copy the expression in px or rem.

Sizing settings

Start
End

Used to convert px to rem.

CSS expression

clamp(1rem, 0.6666667rem + 1.666667vw, 2rem)

Live preview

Computed size23.47 px

Fluid typography

Generate a fluid CSS size

Enter two viewport widths and the desired size at each width. For example, set a heading to 16px at a 320px viewport and 32px at 1280px. Copy the generated clamp() expression into a length property such as font-size, padding, or gap.

How the clamp() expression works

CSS takes a minimum, a preferred value, and a maximum. The preferred value combines a fixed part with a vw part to interpolate between your endpoints. Outside that interval, the size stays at the nearest endpoint. To make a size shrink as the viewport widens, set a smaller end size. The CSS arguments still put the numerically smaller size first.

Choose px or rem

Use px when you want both limits expressed in pixels. Choose rem for limits relative to your site’s root font size and enter the root size your design uses. With a 16px root, 24px equals 1.5rem. If the page’s root font size changes, the effective values and viewport thresholds for a rem-based expression can change too.

Check the result at several widths

Use the preview slider or enter a width to check the computed size in pixels. Compare both endpoints and a viewport in between. The preview applies your chosen root size. For text, test the expression in your page at different widths and zoom levels.

Show more related tools