CSS clamp() Calculator for Fluid Typography & Spacing

Enter a minimum and maximum size and the viewport range — get a zoom-friendly clamp() value with the maths explained, a live preview and a complete fluid type or space scale.

Runs in your browser

Your values

px
px
px
px
px
Browser default is 16px
Quick start

clamp() value

clamp(1rem, 0.8239rem + 0.7512vw, 1.5rem)

font-size: clamp(1rem, 0.8239rem + 0.7512vw, 1.5rem);

Live preview

Fluid type scales smoothly

How this value is calculated

    Fluid scale generator

    Uses the viewport range, root size and output unit from above. Each step interpolates between a mobile and a desktop size.

    VariableMin pxMax pxNow pxclamp()Preview
    CSS custom properties

    Your data never leaves your computer. All processing happens 100% locally in your browser.

    How to use the Clamp Calculator

    1. Enter the min and max size (in px or rem) and the viewport widths where scaling should start and stop.
    2. Copy the clamp() value — choose rem output (recommended for accessibility) or px.
    3. Drag the viewport slider to see the exact size at any screen width, and read the step-by-step maths below.
    4. Generate a complete fluid type scale or space scale and copy it as CSS custom properties.

    What is CSS clamp()?

    clamp(MIN, PREFERRED, MAX) returns the preferred value, but never less than MIN or more than MAX. With a preferred value that grows with the viewport — such as 0.8239rem + 0.7512vw — you get fluid font sizes and spacing that scale smoothly between a mobile and a desktop size, without a stack of media queries. It works in every modern browser.

    The formula, step by step

    Fluid sizing is a straight line between two points: (min viewport, min size) and (max viewport, max size). For 16px at 375px and 24px at 1440px:

    1. Slope = (24 − 16) ÷ (1440 − 375) = 0.007512 — the size grows 0.0075px per pixel of viewport.
    2. vw part = slope × 100 = 0.7512vw, because 1vw is 1% of the viewport width.
    3. Intercept = 16 − 0.007512 × 375 = 13.183px = 0.8239rem at a 16px root.
    4. Result: clamp(1rem, 0.8239rem + 0.7512vw, 1.5rem). At a 768px viewport that’s 13.183 + 0.007512 × 768 ≈ 18.95px.

    Why mix rem and vw?

    A size made only of vw ignores browser zoom and the user’s default font size, which can fail WCAG 1.4.4 (Resize text). Keeping a rem intercept means the value still responds when someone zooms or sets a larger default font. As a rule of thumb, if the maximum is no more than 2.5× the minimum, text can still reach 200% zoom — the calculator flags ranges that exceed this.

    Fluid type and space scales

    Instead of calculating every heading separately, define a modular scale: each step multiplies the base by a ratio. A smaller ratio on mobile (e.g. 1.2, minor third) and a larger one on desktop (e.g. 1.25, major third) keeps headings dramatic on big screens without overwhelming phones — the approach popularised by Utopia. The space scale multiplies the same base (0.25×, 0.5×, 1×, 1.5×, 2×…) so paddings and gaps grow in step with the text.

    How to use clamp() in Webflow

    • Directly in the Style panel: Webflow accepts CSS math functions in size fields. Click into Font size, Padding or Gap, paste the clamp(…) value and press Enter.
    • As variables: create a Size variable for each step (e.g. “Step 0”, “Space M”) in the Variables panel, paste the clamp() value, then apply the variable to fonts and gaps across classes — change it once, update everywhere.
    • Via custom code: paste the generated :root { … } block inside a <style> tag in Site settings → Custom code → Head code, then type var(--step-0) into any size field.
    • Fluid gaps such as clamp(2rem, …, 4rem) keep sections from feeling oversized on tablets — use the Gap quick-start chip.

    Converting design specs first? The PX to REM Converter turns pixel values into rem.

    Tools that pair well with the Clamp Calculator

    • Box Shadow Generator — Stack multiple shadow layers, tweak offsets, blur, spread and opacity on a live card, then copy the box-shadow or text-shadow CSS.
    • CSS Gradient Generator — Design a gradient visually — drag colour stops, change the angle or type, start from a preset — and copy production-ready CSS with a solid fallback colour.
    • Unit Converter — Convert between metric, imperial and technical units in ten categories — with a two-way converter and a table of every unit at once.
    • Aspect Ratio Calculator — Resize images and videos without distortion: fill in a ratio and one side to get the other, or enter a size to find its ratio — with ready-to-paste CSS.

    Frequently asked questions

    What is a good min and max viewport for fluid typography?
    Common choices are 320–390px for the minimum (small phones) and 1240–1440px for the maximum (typical content width or laptop). Below and above the range the value stays fixed, so pick the widths where your layout actually changes.
    Should the clamp() output use rem or px?
    Use rem. A rem intercept respects the user’s browser font-size setting and zoom, while a px-only or vw-only value can fail WCAG 1.4.4. Pixel output is offered for cases like borders or offsets where that doesn’t matter.
    Can clamp() make a value shrink on bigger screens?
    Yes. Enter a max size smaller than the min size; the slope becomes negative and the calculator still puts the smaller value first in clamp(), as CSS requires.
    Does clamp() work in Webflow?
    Yes. You can paste clamp() into size fields in the Style panel, store it in Size variables, or define the generated custom properties in custom code and reference them with var().
    Why does my fluid font size not change when I resize the browser?
    Check that the viewport is inside your min/max range, that the vw coefficient isn’t tiny, and that no other rule overrides the property. Also note that vw includes the vertical scrollbar width on desktop.
    How is this different from using media queries?
    Media queries jump between fixed sizes at breakpoints; clamp() interpolates continuously, so every screen width gets an appropriate size with one line of CSS and no breakpoint jumps.

    Related tools