About this tool
Fluid sizing makes text and spacing grow smoothly with the screen instead of jumping at breakpoints. Enter the size you want on small screens and on large screens, and the viewport widths where each should apply. The calculator writes a clamp() value that stays at the minimum below the small width, at the maximum above the large width, and scales in a straight line between.
How the formula works
clamp(MIN, PREFERRED, MAX) uses the preferred value but never goes below MIN or above MAX. The preferred value is a line through two points, (small viewport, min size) and (large viewport, max size):
slope = (maxSize − minSize) / (maxViewport − minViewport)
intercept = minSize − slope × minViewport
preferred = intercept + slope × 100vw
With 18px at 360px and 32px at 1280px, the slope is 14 / 920 ≈ 1.522vw and the intercept 12.52px, giving clamp(1.125rem, 0.7826rem + 1.5217vw, 2rem).
Accessibility: keep a rem part
A size made only of vw ignores the user’s browser font-size setting and can’t be enlarged with zoom in some cases, which fails WCAG 1.4.4 (Resize text). Outputting in rem keeps the minimum, maximum and intercept tied to the user’s font size. Keep the maximum no more than about 2.5 times the minimum so that zooming to 200% still enlarges the text.
Fluid type scales
The type scale below generates a full set of heading sizes, where each step is a fixed ratio larger than the previous one. Using a smaller ratio on phones and a larger one on desktops keeps big headings from overwhelming small screens.
FAQ
What is CSS clamp()?
clamp(min, preferred, max) returns the preferred value, limited to the range between min and max. With a viewport-based preferred value, it makes fluid sizes.
How do I make font size responsive without media queries?
Use font-size: clamp(1.125rem, 0.78rem + 1.52vw, 2rem). This calculator works out the numbers from your minimum and maximum sizes.
Why use rem instead of px in clamp()?
rem values follow the user’s browser font size, so text still grows for people who set a larger default. Pure vw sizes don’t.
Is clamp() supported in all browsers?
Yes, in every current browser since 2020.
Can I use clamp() for spacing?
Yes. Change the property to padding, margin or gap. Fluid spacing keeps proportions consistent across screen sizes.