CSS Clamp Calculator
Work out a clamp() value that scales smoothly between a smallest and a largest size across a range of screen widths.
How to make fluid sizes with clamp
Enter the sizes
The smallest and the largest, in pixels.
Enter the screen widths
Where growing starts and stops.
Copy the CSS
Use the rule for font sizes, spacing or widths.
Worked example
This is what CSS Clamp Calculator gives for its own sample values. Open the tool above and change anything to try your own.
- Smallest size (px)
- 16
- Largest size (px)
- 32
- Screen width where it starts growing (px)
- 320
- Screen width where it stops growing (px)
- 1280
- Root font size (px)
- 16
- CSS property
- font-size
CSS
font-size: clamp(1rem, 0.6667rem + 1.6667vw, 2rem);
Result
- clamp() value
- clamp(1rem, 0.6667rem + 1.6667vw, 2rem)
- Slope
- 1.6667vw
- Intercept
- 10.6667px
About CSS Clamp Calculator
Work out a clamp() value that scales smoothly between a smallest and a largest size across a range of screen widths, with no media queries. The result is in rem so it respects the visitor's font size.
FAQs
Why does the middle part use vw?
Viewport width units change as the window resizes, which makes the size grow with the screen.
Is fluid text accessible?
Yes, as long as the value includes a rem part, as these results do, so zoom and font settings still work.