Frontend Tools
CSS clamp() Generator for Fluid Sizes
Generate a fluid CSS clamp() value from a minimum and maximum size and a viewport range, in rem or px, with a table of computed sizes at common screen widths.
How to use CSS clamp() Generator for Fluid Sizes
Enter the minimum and maximum sizes and the viewport widths where scaling starts and stops, then choose rem or px output, the root font size and the CSS property. Copy the declaration and check the size table.
- Set the size rangeEnter the minimum size for small screens and the maximum size for large screens, both in px.
- Set the viewport rangeChoose where scaling starts and stops, such as 360px and 1440px. Outside that range the size stays fixed.
- Pick the output and copyChoose rem or px, the root font size and a property such as font-size or gap, then copy the code.
How the preferred value is calculated
The middle value of clamp() is a straight line between two points. Slope = (max size − min size) ÷ (max viewport − min viewport), and slope × 100 gives the vw figure. The intercept is min size − slope × min viewport. For the defaults, 16px to 32px between 360px and 1440px, the slope is 16 ÷ 1080, giving 1.4815vw, and the intercept is about 10.6667px, or 0.6667rem with a 16px root: font-size: clamp(1rem, 0.6667rem + 1.4815vw, 2rem). At a 768px viewport that works out at about 22.04px.
rem, px and zoom accessibility
With rem output, the minimum, maximum and intercept are converted using the root font size, so text follows the user's browser font size setting. px output gives clamp(16px, 10.6667px + 1.4815vw, 32px), which ignores that setting. Because part of the value is in vw, zooming has less effect on it, and if the maximum is more than 2.5 times the minimum, text may not reach 200% when zoomed, as WCAG 1.4.4 requires; the tool warns you. If the small-screen size is the larger one, the value shrinks as the viewport grows.
Accuracy and data handling
After adding generated code to a project, test it in the target browsers and responsive sizes. The calculation runs in your current browser; the tool code does not send the input to a processing API.
FAQ
What do the three values in CSS clamp() mean?
They are the minimum, the preferred value and the maximum. The browser works out the preferred value, such as 0.6667rem + 1.4815vw, and keeps the result between the minimum and the maximum.
How is the vw value in clamp() calculated?
vw = (max size − min size) ÷ (max viewport − min viewport) × 100. For 16px to 32px across viewports from 360px to 1440px, that's 16 ÷ 1080 × 100 ≈ 1.4815vw.
Which browsers support clamp()?
Chrome and Edge 79, Firefox 75 and Safari 13.1 onwards support clamp(), so every current major browser does. Internet Explorer never did.
More Frontend Tools
Related toolsScore CSS selectors as (A, B, C) and rank them by specificity.
Generate CSS transition code with easing presets, a curve preview and reduced-motion CSS.
Build responsive CSS grid columns with auto-fit, auto-fill or a fixed count, previewed live.
Shrink HTML by removing comments and spare whitespace, with the byte saving shown.
Strip comments and whitespace from JavaScript safely, with the size saving shown.
Indent messy or minified HTML into readable, nested lines, including inline CSS and JS.