CSS Clamp / Responsive Font Size Generator

Last updated: What’s new

rem
rem
px
px
Live preview (resize your window to see it scale)

The quick brown fox jumps over the lazy dog.

Runs in your browser. Nothing is uploaded.

Know a business that needs a website or SEO?

Introduce them and earn a referral reward. They work with us directly.

  • Projects: 10%, at least $100
  • Monthly services: 10% for the first six months

Refer someone now

See 36 client websites

How Fluid Type Is Calculated

  1. Two anchor points, your min size at the min viewport and max size at the max viewport.
  2. Find the slope, the change in size divided by the change in viewport width gives a vw value.
  3. Find the intercept, a fixed rem term keeps text zoomable and accurate.
  4. Wrap in clamp(), the min and max bounds stop the size going too small or too large.

Why Fluid Type Helps

  • Fewer media queries, one clamp() replaces several breakpoint rules.
  • Looks right everywhere, type scales continuously instead of jumping.
  • Accessible, a rem component keeps text zoomable for users who need it.
  • Cleaner CSS, less code to maintain and fewer edge cases to test.

Fluid typography is one of the techniques we lean on in our web design services to build sites that look sharp on every screen without a pile of breakpoints to maintain.

CSS clamp() Reference

The clamp() function takes three arguments in the form clamp(MIN, PREFERRED, MAX). The browser uses the preferred value but never lets it fall below the minimum or rise above the maximum.

PartRoleExample
MINThe smallest value allowed. The result never goes below this on small screens.1rem
PREFERREDThe target value, usually a rem plus vw formula so it scales with the viewport.0.5rem + 2vw
MAXThe largest value allowed. The result never goes above this on wide screens.2rem

Put together, that example reads clamp(1rem, 0.5rem + 2vw, 2rem): it stays at 1rem on narrow screens, scales fluidly in the middle, and locks at 2rem once it gets large.

Fluid Typography Examples

Starting points for a fluid type scale between a 360px and a 1280px viewport: each value is at its minimum at 360px and reaches its maximum at 1280px. Tune the numbers in the generator above to fit your design.

Use caseclamp() value
Hero heading (H1)clamp(2rem, 1.2174rem + 3.4783vw, 4rem)
Section heading (H2)clamp(1.5rem, 1.1087rem + 1.7391vw, 2.5rem)
Subheading (H3)clamp(1.25rem, 1.0543rem + 0.8696vw, 1.75rem)
Body textclamp(1rem, 0.9511rem + 0.2174vw, 1.125rem)
Lead paragraphclamp(1.125rem, 0.9783rem + 0.6522vw, 1.5rem)
Section paddingclamp(2rem, 0.4348rem + 6.9565vw, 6rem)
Grid gapclamp(1rem, 0.413rem + 2.6087vw, 2.5rem)

Building a consistent fluid type scale by hand is fiddly. If you would rather hand it off, our web design services ship responsive, accessible design systems that look sharp on every device.

What’s new

  • The fluid typography examples are now generated with the tool itself, so each reaches its maximum at 1280px.

CSS Clamp Generator: FAQ

What does this CSS clamp generator calculate?
It builds a linear clamp() value from two anchor points: a size at the minimum viewport width and a size at the maximum viewport width. Between those widths the preferred rem plus vw expression scales linearly, while the first and third arguments cap the result.
Why does the generated output use rem even when I enter px?
The px option describes the units of the minimum and maximum inputs. The tool converts those sizes to rem using the selected root font size, then outputs rem bounds and a rem plus vw preferred value. This preserves one consistent generated format.
What does the root font-size selector change?
It controls the conversion between px and rem and the fixed rem intercept in the preferred formula. Choose the actual root size used by your site, usually 16px. A mismatch means the generated curve will hit different pixel sizes than intended.
What happens if the minimum size is greater than the maximum?
The calculation supports a decreasing scale. It produces a negative vw slope and orders the clamp bounds from the smaller rem value to the larger one. Preview the result across the viewport range to confirm that shrinking with width is intentional.
Why does the tool show Enter valid numbers?
One or more inputs are empty or not numeric, or the minimum and maximum viewport widths are identical. Two different viewport widths are required to calculate a slope. The tool does not otherwise validate whether the chosen sizes or widths are sensible for the design.
Can I use the generated value for spacing or width?
The clamp() value can be used in CSS length properties that accept its units. However, the Copy button prepends font-size:. For padding, margin, gap, or width, copy the value from the output field and place it after the property you need.
Does the live preview prove the type is accessible?
No. It only applies the generated value to one preview paragraph at the current browser width. Test browser zoom, user font settings, small and large screens, wrapping, line height, and component layout. A rem term supports resizing but does not guarantee WCAG conformance.
Are my clamp inputs sent to Web Aloha?
No. The slope, intercept, unit conversion, preview, and copy action run in the browser. The generator makes no calculation request to a Web Aloha endpoint, so the entered sizes and generated CSS are not uploaded by this feature.