Before clamp(), building a fluid scale meant stacking media queries:
set a font size for mobile, override it at 768 px, override again at 1200 px.
The result was a stepped scale — values jumped between breakpoints rather than
flowing continuously. Every new breakpoint needed its own rule, and every design
change rippled through all of them.
clamp(min, preferred, max) is a CSS math function introduced in the
CSS Values and Units Level 4 spec. It evaluates its middle argument — the
preferred value — and clamps the result so it never falls below
min or exceeds max. The preferred value is typically a
viewport-relative expression like 4vw or 2vw + 1rem,
which is what makes the output fluid: it grows smoothly with the viewport
without ever leaving the guardrails.
Browser support is universal across all modern engines. It works on
font-size, padding, margin,
gap, width, border-radius — any property
that accepts a length, percentage, or number.