CSS Clamp Generator
Settings
CSS Property
Unit
Small Screen
Minimum size, applies at the smallest viewport.
Large Screen
Maximum size, applies at the largest viewport.
Viewport Range
Scaling activates between these breakpoints.
Generated CSS
Presets
Click a preset to load common values.
Live Preview
Hero heading
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Heading
Body text
Heading
Body text
Heading
Body text
How clamp() Works
The CSS clamp() function takes three parameters: a minimum value, a preferred value, and a maximum value.
The browser selects the preferred value whenever it falls between the minimum and maximum bounds.
If the preferred value drops below the minimum, the minimum is used. If it exceeds the maximum, the maximum is used.
This enables fluid typography and spacing — values that scale smoothly between viewport breakpoints
without needing media queries. The formula for the preferred value uses viewport units (vw) and a base offset
to create a linear interpolation between the min and max sizes across the chosen viewport range.
Practical Examples
/* Fluid heading: scales from 32px to 72px between 480px and 1200px */
h1 {
font-size: clamp(2rem, 4.4444vw + 0.6667rem, 4.5rem);
}
/* Fluid padding: scales from 16px to 48px */
.container {
padding: clamp(1rem, 3.5556vw + 0.0667rem, 3rem);
}
/* Fluid gap with rem units */
.grid {
gap: clamp(0.75rem, 2.2222vw + 0.3333rem, 1.5rem);
}
For consistent scaling, pair clamp() with a typographic scale and use rem units
to respect user font-size preferences. This approach eliminates hard breakpoints and creates
a truly responsive design that adapts to every screen size.
Frequently Asked Questions
clamp() support?px, rem, em, vw, vh, %, ch, etc.) You can mix units within the same clamp() function, but the typically using vw is preferred for responsive/fluid scaling.clamp()'s browser support?clamp() is supported in all modern browsers (Chrome 79+, Firefox 75+, Safari 13.1+, Edge 79+). It works on desktop and mobile.clamp() instead of min() or max()?clamp() when you need to define an upper and lower bound - it combines max(min, preferred) and min(preferred, max). Otherwise, min() is for only an upper bound, and max() is for a lower bound.clamp() improve accessibility?rem, clamp() uses the user's browser font settings. This means content remains readable at all zoom levels without dreadful horizontal scrolling.Similar Tools
CSS Gradient Generator
arrow_forwardGenerate beautiful CSS gradients
Button Generator
arrow_forwardGenerate captivating buttons for any purpose
CSS Neumorphism Generator
arrow_forwardCreate neumorphism depth effects with CSS
CSS Tools arrow_forward
CSS tools for creating rich and polished user interfaces