CSS clamp() Generator

clamp() lets a size grow smoothly with the screen width, between a minimum and a maximum, without media queries. Enter the smallest and largest size and the screen widths where growing should start and stop, and copy the clamp() value for font-size, padding, gap, margin, width or border-radius. Drag the preview width to see the size at any screen.

px
px
px
px
px

16 unless your site changes html { font-size }

Output unit

Fluid text

Screen width3607681024128014401920
Size (px)1630.239.1484848
Code
font-size: clamp(1rem, 0.2174rem + 3.4783vw, 3rem);

Calculating runs in your browser. What you type never leaves this device.

Features

  • For font-size, padding, margin-block, gap, width and border-radius

  • rem output by default, so text still respects the reader's font size

  • Handles sizes that shrink as the screen grows

  • Live preview at any screen width, plus a table at common widths

  • Copy as CSS, a CSS variable or a Tailwind class

Where fluid sizes help

Section spacing

Padding that is comfortable on phones and generous on desktops, in one line.

Headings

A hero heading that fills a desktop screen but still fits a phone.

Grids and cards

Gaps and widths that scale between breakpoints instead of jumping.

How clamp() is calculated

The maths

The middle value is a straight line between your two points: slope = (max size - min size) ÷ (max width - min width). It is written as a fixed rem part plus a vw part, for example clamp(1rem, 0.8182rem + 0.9091vw, 1.5rem). Below the first width the size stays at the minimum; above the second, at the maximum.

Why rem in the middle term

If the middle value used only vw, zooming the page would not make text bigger, which fails WCAG 1.4.4 (resize text). Mixing rem and vw keeps text responsive to both the screen and the reader's settings.

Good starting values

  • Screen widths: 360 px (small phones) to 1280 or 1440 px (laptops).
  • Body text: 16 to 18 px. Large headings: 32 to 56 px.
  • Section padding: 24 to 96 px.

Related tools

CSS clamp() Generator - FAQ