CSS clamp() Fluid Typography Generator
Enter min and max font sizes and viewport widths to get a clamp() rule in rem and vw, with no media queries.
Fluid typography with clamp(): the rem + vw formula and example
A fluid size grows in a straight line between two screen widths: slope = (max size − min size) ÷ (max viewport − min viewport), expressed in vw, plus a constant in rem. From 16 px at 375 px wide to 32 px at 1,440 px, the tool outputs clamp(1rem, 0.6479rem + 1.5023vw, 2rem).
The formula
- Slope m = (max size − min size) ÷ (max viewport − min viewport), in px per px.
- Intercept b = min size − m × min viewport, in px.
- Preferred value = b ÷ 16 rem + m × 100 vw (1 vw = 1% of the window width).
- Bounds: min size ÷ 16 and max size ÷ 16 in rem; in px mode, values stay in pixels.
Worked example
Viewports 375 and 1,440 px, sizes 16 and 32 px: m = 16 ÷ 1,065 = 0.015023, i.e. 1.5023 vw; b = 16 − 0.015023 × 375 = 10.37 px, i.e. 0.6479 rem. Result: clamp(1rem, 0.6479rem + 1.5023vw, 2rem). At 768 px wide the font is 10.37 + 0.015023 × 768 = 21.90 px; it stays at 16 px below 375 px and at 32 px above 1,440 px.
Assumptions and limits
- The rem conversion assumes 16 px per rem, the browser default. If your stylesheet changes the root font size, recalculate.
- The rem part follows the user's font-size setting while the vw part only follows window width. The steeper the slope, the less zoom enlarges the text: check that text stays readable at 200% (WCAG success criterion 1.4.4).
- If the two viewports are equal, no slope can be computed: the tool then returns a 0 vw slope and a fixed size equal to the minimum size. If the minimum size is larger than the maximum, the clamp() bounds are put back in order (smaller first) and the size shrinks as the screen gets wider.
Sources and dates: W3C, WCAG 2.2, success criterion 1.4.4 Resize Text, Recommendation of 12 December 2024 (checked 10/14/2026).
Frequently Asked Questions
How do I read a CSS clamp() value?
clamp(min, preferred, max) returns the preferred value as long as it stays between the two bounds. With clamp(1rem, 0.6479rem + 1.5023vw, 2rem), the font is 16 px on small screens, 32 px on large ones and grows linearly in between.
Why mix rem and vw in the preferred value?
A size in vw alone ignores the browser's font-size setting. The rem part keeps that response, which helps meet the 200% text resize required by WCAG success criterion 1.4.4.
How many pixels is 1 rem?
16 px by default, the browser base size, so the tool divides pixels by 16. If your CSS sets html to 62.5%, 1 rem equals 10 px and the generated values must be recalculated.
Which viewports should I use for fluid type?
The defaults, 375 px (small smartphone) and 1,440 px (wide laptop screen), cover most cases. Outside that range, the size stays fixed at the minimum or maximum.
Is this tool really free?
Yes, all tools on Kristools are 100% free and accessible without registration.
Is my data protected?
Yes. All processing is performed directly and securely inside your browser. No personal data is sent to our servers.