CSS clamp() Calculator (Fluid Typography)
Software · 6 inputs · Free
CSS clamp() Calculator (Fluid Typography)
Parameters
What is this tool?
CSS clamp() Calculator (Fluid Typography) helps developers with encoding, encryption and text processing. Calculates the CSS clamp() expression for a font size that scales fluidly with the viewport width. Slope = (max size − min size) ÷ (max viewport − min viewport), intercept = min size − slope × min viewport; the result is given as font-size: clamp(min, intercept + slope × 100vw, max) in rem or px. The slope, the intercept and the size at three sample viewport widths are shown too. Values are rounded to 4 decimal places.
📘 Common mistakes · Worked exampleCalculates the CSS clamp() expression for a font size that scales fluidly with the viewport width. Slope = (max size − min size) ÷ (max viewport − min viewport), intercept = min size − slope × min viewport; the result is given as font-size: clamp(min, intercept + slope × 100vw, max) in rem or px. The slope, the intercept and the size at three sample viewport widths are shown too. Values are rounded to 4 decimal places.
The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.
Last reviewed: · Methodology and sources
How is it calculated?
Calculates the CSS clamp() expression for a font size that scales fluidly with the viewport width. Slope = (max size − min size) ÷ (max viewport − min viewport), intercept = min size − slope × min viewport; the result is given as font-size: clamp(min, intercept + slope × 100vw, max) in rem or px. The slope, the intercept and the size at three sample viewport widths are shown too. Values are rounded to 4 decimal places.
Inputs
| Value | Unit | Example |
|---|---|---|
| Minimum font size | px | 16 |
| Maximum font size | px | 24 |
| Minimum viewport width | px | 320 |
| Maximum viewport width | px | 1280 |
| Root font size | px | 16 |
| Output unit | — | rem |
What is this tool?
CSS clamp() Calculator (Fluid Typography) helps developers with encoding, encryption and text processing. Calculates the CSS clamp() expression for a font size that scales fluidly with the viewport width. Slope = (max size − min size) ÷ (max viewport − min viewport), intercept = min size − slope × min viewport; the result is given as font-size: clamp(min, intercept + slope × 100vw, max) in rem or px. The slope, the intercept and the size at three sample viewport widths are shown too. Values are rounded to 4 decimal places.
Common mistakes
- Setting the font size in vw alone. font-size: 2vw becomes unreadably small on narrow screens, grows without limit on wide ones and ignores the user's font-size setting; add bounds with clamp() and the user's preference with rem.
- Using the px output. When the bounds and the intercept are in px, the browser's font-size setting is ignored, which is why the tool adds a warning under px output.
- Entering the wrong root font size. If the site has a rule such as html { font-size: 62.5% }, 1rem is 10 pixels; leaving the root at 16 makes every rem value 1.6 times too small.
- Rounding the slope or intercept by hand. Writing 0.8vw in place of 0.8333vw lowers the size at the maximum viewport by about 0.4 pixels; copy the tool's four-decimal values as they are.
- Choosing a very large ratio between the minimum and maximum size. The steeper the slope, the larger the vw-dependent share and the less the text grows under zoom; do not publish without testing at 200% zoom.
- Assuming vw is measured against the parent element. vw is always the width of the viewport; text inside a narrow sidebar is sized by the window, not by the sidebar.
- Writing the bounds in the wrong order. In an expression such as clamp(1.5rem, …, 1rem) the specification lets the minimum win, so the result is always 1.5rem.
📘 How to Calculate Fluid Font Sizes with CSS clamp() →
Sources
- W3C — CSS Values and Units Module Level 4: comparison functions min(), max() and clamp() ↗
- W3C — CSS Values and Units Module Level 4: viewport-percentage lengths (vw) ↗
- W3C — WCAG 2.2, Success Criterion 1.4.4: Resize Text ↗
Key terms
Frequently Asked Questions
+CSS clamp() Calculator (Fluid Typography) — how is it calculated?
Calculates the CSS clamp() expression for a font size that scales fluidly with the viewport width. Slope = (max size − min size) ÷ (max viewport − min viewport), intercept = min size − slope × min viewport; the result is given as font-size: clamp(min, intercept + slope × 100vw, max) in rem or px. The slope, the intercept and the size at three sample viewport widths are shown too. Values are rounded to 4 decimal places.
+Which values are required?
Minimum font size (px), Maximum font size (px), Minimum viewport width (px), Maximum viewport width (px), Root font size (px), Output unit.
+Is my data stored?
No. All calculations run in your browser; the values you enter are never sent to or stored on a server. If you press “Save”, the calculation stays only in your own browser and you can delete it at any time.
+Is it free?
Yes, all tools are free and require no sign-up.
Similar tools
Popular Tools
Free Calculators in One Place
Tax, finance, health, math and more — 500+ tools, all in one place.