Developer

Runs in your browser. No file uploads for processing.

CSS Clamp Calculator for Fluid Type and Spacing

Generate a CSS clamp() value from two viewport widths and two sizes. Compare rem output at different root font sizes.

Loading tool...

How to generate a fluid CSS clamp value

  1. Pick two viewport widths

    Use the narrowest and widest widths where you want the property to change. For example, start at 320 px and stop at 1,600 px.

  2. Enter a size at each end

    For 1 rem to 2 rem with a 16 px design root, the result is clamp(1rem, 0.75rem + 1.25vw, 2rem). At a 960 px viewport the value is 24 px at this design root.

  3. Copy it and check text scaling

    Paste the value into an appropriate CSS declaration. Use the root-size comparison to see the estimate at another root and check real browser zoom and accessibility separately.

Use cases

  • Create a fluid heading that levels off at a chosen minimum and maximum.
  • Set spacing that changes over a viewport range instead of adding several media queries.

Limits and privacy

  • Calculates a linear value between two viewports; not container-query units or an entire type scale. Root and viewport use CSS pixels for this estimate.
  • Numbers are rounded for a copyable CSS value. Changing the root size can shift the width where clamping starts or stops. Test actual zoom, text scaling and layouts separately.

The tool processes inputs in your browser. Account features and usage analytics are separate.

Frequently asked questions

What else can I check for readable type?

After testing the type size in the actual layout, use Color Contrast Checker to check text and background colors. Font size alone does not guarantee legibility.

What does CSS clamp() do here?

It keeps the preferred fluid value between the stated lower and upper limits.

Can a value get smaller as the screen gets wider?

Yes. Set a later viewport with a smaller size. The generated preferred value uses a negative viewport contribution and sorts the clamp bounds.

Does rem mean the result always passes text zoom requirements?

No. The combined rem and viewport terms behave differently under scaling. Use the root estimate to see the tradeoff, then test your layout in real browsers.

Can this be used for spacing, not only font size?

Yes. Use it for a CSS property that accepts the resulting length, such as padding, gap or margin.

Related tools