CSS Clamp Generator

Set a minimum, preferred (fluid), and maximum value to calculate responsive font sizes, spacing, and widths.
Generate CSS that scales smoothly with the viewport — no complicated math, no media queries.

📏 Viewport Range

px
px

📐 Size Range

px
px
px
clamp(1rem, 0.5rem + 1.5vw, 2rem)

✨ Live Preview

Resize your browser window to watch the text scale
The quick brown fox jumps over the lazy dog
0123456789 !@#$%

📖 How to use

  • Viewport Range: set the range of screen widths where the value should scale (mobile → desktop).
  • Size Range: enter the element's size at the smallest and largest viewport.
  • Generated Code: a clamp() rule that scales smoothly without media queries is generated as you type.
  • Copy the code and apply it to font-size, padding, and more!

CSS Clamp Generator: Fluid Typography Done Right

The CSS Clamp generator is the best way to build responsive fonts and layouts that scale smoothly without media queries. It produces optimal responsive code in real time — no manual math required.

1. What is the CSS clamp() function?

clamp() is a modern CSS function that constrains a value with three parameters: minimum, preferred, and maximum. The element's size follows the preferred value as the screen scales, but never drops below the minimum or exceeds the maximum.

2. Why use clamp()?

3. How the calculation works

This generator uses linear interpolation to compute the ideal preferred value. You only enter the min/max font size and the min/max viewport width — the generated calc() expression lets the browser work out the exact pixel value for any screen size.

4. Practical tips

Don't stop at font sizes — clamp() works great for padding, margin, and width too. Applying it to hero titles and content gutters keeps your designer's intended proportions intact on every resolution.

Frequently Asked Questions

Q. How does the CSS clamp() function work?

clamp(minimum, preferred, maximum) lets the preferred value scale with the viewport while never going below the minimum or above the maximum.

Q. Should I use clamp() or media queries?

Use clamp() for values that should change continuously, like font sizes and spacing. Use media queries when the layout structure itself changes. Most projects use both together.

Q. How well is clamp() supported in browsers?

clamp() is supported in every major browser released since 2020 (Chrome 79+, Safari 13.1+, Firefox 75+, Edge 79+), covering well over 95% of users worldwide.

Q. How is the vw value in the preferred parameter calculated?

By linear interpolation between your four inputs: min/max font size and min/max viewport width. The generator solves the equation and outputs a ready-to-copy clamp() rule.