It's a CSS function that constrains a value between a minimum and a maximum. In the middle it accepts any CSS expression — typically `viewport-width + rem-constant` for fluid typography.
CSS Clamp Calculator
Generate fluid responsive values with clamp() — typography and spacing that scale smoothly.
Before clamp(), responsive typography meant a media query for every breakpoint. With clamp(), scaling happens continuously between two screen sizes.
The CSS `clamp(min, preferred-value, max)` is a mathematical function that constrains a value between a minimum and a maximum. For fluid typography, the preferred value is a combination of `vw` (viewport width) with a fixed `rem` offset, geometrically derived from the target font sizes and viewport widths. The slope formula is simple: `(maxPx - minPx) / (maxVp - minVp)`. The intercept positions the line at the origin. The result is text that scales pixel-by-pixel between viewports with no jumps at all.
Set the extremes and let the math work.
- Define the minimum and maximum size (in px or rem) and the bounding viewports where each size applies.
- Review the detailed calculation with slope and intercept, then check the three-scale preview.
- Copy the CSS and paste it into your token file or global CSS variable.
Sources and references for this tool
These references help contextualize formulas, standards, APIs and limitations used on this page. They do not replace professional validation when a result has legal, financial, medical or operational impact.
- clamp()MDN Web Docs — Clamp function reference with examples for fluid typography and spacing.
- CSS Values and Units Module Level 4 — clamp()W3C — Formal specification of CSS math functions including clamp().
- Fluid Typography — Josh W. ComeauJosh W. Comeau — Reference technical article on the slope-intercept formula for fluid typography with clamp().