How the calculator works
The tool draws a straight line between two points: your minimum size at the minimum viewport width, and your maximum size at the maximum viewport width. clamp() keeps the value on that line and stops it at either end, so nothing grows past your maximum or shrinks below your minimum.
clamp(min, intercept + slope * 100vw, max)What to use it for
Use fluid values for font sizes, padding, margins, gap and section spacing: anywhere you would otherwise write a media query just to change one number. One declaration replaces two or three breakpoints.
Keep it accessible
Output in rem, not px. A value built only from vw ignores browser zoom, so readers who enlarge text see no change. The rem part of the preferred value keeps zoom working.
How to use the calculator
- Enter the smallest and largest size you want, in pixels.
- Enter the narrowest and widest screen widths where the size should change. 320px and 1280px are a good start.
- Choose rem or px output and the CSS property.
- Copy the generated line into your stylesheet.
A worked example
For a heading that should be 24px on a 320px screen and 48px on a 1280px screen, the slope is 24 / 960 = 0.025, which is 2.5vw. The intercept is 24 - 0.025 x 320 = 16px, or 1rem. The result is clamp(1.5rem, 1rem + 2.5vw, 3rem).
Learn more
Read the CSS clamp() guide for syntax and common mistakes, or the responsive font size guide to compare methods.