CalcWorldHub
Free online calculator · no signup

CSS Fluid Typography Clamp Calculator

Generate a CSS clamp() expression that scales a font size between two viewport widths.

4,000 tools
CSS Fluid Typography Clamp Calculator — Minimum font size (CSS px), Maximum font size (CSS px), Minimum viewport width (CSS px) and calculation method
CSS Fluid Typography Clamp Calculator: inputs and calculation method.

How to use this calculator

Generate a CSS clamp() expression that scales a font size between two viewport widths.

  1. Enter Minimum font size (CSS px), Maximum font size (CSS px), Minimum viewport width (CSS px), Maximum viewport width (CSS px). Match the units shown beside each field and review the result together with the assumptions below.
  2. Read the worked example below to check the expected input format and result.
  3. Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Computer science calculation

How this calculation works

A fluid type rule can grow linearly across a chosen viewport interval and stop at explicit minimum and maximum sizes. This calculator solves the line through the two size-width endpoints, then places that line inside CSS clamp() so it stays bounded outside the interval.

Inputs and units

fontMin — Minimum font size (CSS px)
The lower clamp bound and the size at the minimum viewport width.
fontMax — Maximum font size (CSS px)
The upper clamp bound and the size at the maximum viewport width.
viewportMin — Minimum viewport width (CSS px)
At this width the preferred size reaches the entered minimum.
viewportMax — Maximum viewport width (CSS px)
At this width the preferred size reaches the entered maximum.

Formula

Displayed formula

b = 100 × (fontMax − fontMin)/(viewportMax − viewportMin). a = fontMin − b × viewportMin/100. Preferred size = a px + b vw. CSS output = clamp(fontMin px, calc(a px + b vw), fontMax px).

Method

Enter the smaller and larger font sizes in CSS pixels and the viewport widths where each size should be reached. The calculator derives the slope in vw units and the pixel intercept, then writes a clamp() expression with the entered lower and upper bounds.

Worked example

For 16 px at 360 px viewport width and 32 px at 1,200 px, b = 100 × 16/840 = 1.904762 and a = 16 − 1.904762 × 3.6 = 9.142857. The generated rule is clamp(16px, calc(9.142857px + 1.904762vw), 32px), which evaluates to 16 px and 32 px at the two endpoints.

Assumptions and limits

The preferred value is linear and assumes the entered viewport width is the only scaling variable. The output uses CSS px, vw, and clamp(); it does not choose design endpoints, test a full stylesheet, or assess readability. Browser zoom and project-specific typography rules still need review.

Frequently asked questions

What does CSS clamp() do?

It returns a preferred value bounded by a minimum and maximum, so the fluid size cannot fall below or exceed the entered limits.

Why use vw in the middle expression?

A vw term changes with viewport width. The pixel intercept shifts the line so it passes through the two chosen endpoint pairs.

Does this calculate a recommended font size?

No. It only fits a linear rule to your chosen endpoints. Choose sizes and breakpoints based on the design and content.

Can I paste the result into a stylesheet?

Yes. The output is a CSS clamp() value for a property such as font-size; review it in the context of your stylesheet and browser targets.

How do I use the CSS Fluid Typography Clamp Calculator?

Enter Minimum font size (CSS px), Maximum font size (CSS px), Minimum viewport width (CSS px), Maximum viewport width (CSS px). Match the units shown beside each field and review the result together with the assumptions below.