The CSS functions min(), max() and clamp() pick a value from a list at layout time. min() returns the smallest value, max() returns the largest, and clamp(minimum, preferred, maximum) returns the preferred value but never lets it go below the minimum or above the maximum. Together, the css clamp min max functions let you write responsive sizes without media queries.
This guide shows how each one resolves, the typical uses for widths and fluid typography, how they differ from min-width and max-width, and the accessibility point you must not skip when you size text.
min() takes two or more values and returns the smallest one. Units can be mixed, and the choice is re-evaluated whenever the viewport or container changes.
On a wide screen, 90% of the parent is larger than 1100px, so the width is 1100px. On a narrow screen, 90% is smaller, so the width is 90%. This single line replaces width: 90%; max-width: 1100px;, and the two forms are equivalent. Think of min() as "never larger than the smallest of these".
max() returns the largest value from the list. Think of it as "never smaller than the largest of these".
The first rule keeps padding at least 0.75rem, growing with the viewport after that. The second is a common mobile pattern: use at least 1rem, but more on devices with a notch where the safe area inset is larger.
clamp() takes three arguments in the order minimum, preferred and maximum. It is equivalent to max(minimum, min(preferred, maximum)).
The size follows 1rem + 3vw while that value stays between 1.75rem and 3.5rem. Below that range the heading stays 1.75rem, above it the heading stops at 3.5rem. This is the standard recipe for fluid typography.
| Viewport width (16px root) | 1rem + 3vw | Result |
|---|---|---|
| 320px | 25.6px | 28px (minimum, 1.75rem) |
| 600px | 34px | 34px (preferred) |
| 1200px | 52px | 52px (preferred) |
| 1600px | 64px | 56px (maximum, 3.5rem) |
All three functions accept math expressions directly, so you do not need to write calc() inside them. Operators follow the same spacing rules as calc(): put spaces around + and -.
Percentages inside these functions are resolved against the same reference as the property they appear in, so 5% in padding is relative to the containing block's width.
Using only vw for font size is an accessibility problem. Text sized purely in vw does not grow when the user zooms the page or raises the default font size, which can break WCAG requirements for resizable text. The fix is to include a rem term in the preferred value, as in 1rem + 3vw, and to use rem for the bounds.
A good check is to zoom the page to 200 percent and confirm that text becomes larger. If the bounds are rem based, it does.
| Goal | Classic way | With functions |
|---|---|---|
| Fluid with a cap | width: 90%; max-width: 1100px; | width: min(90%, 1100px); |
| Fluid with a floor | width: 50%; min-width: 300px; | width: max(50%, 300px); |
| Fluid with both | Three declarations | width: clamp(300px, 50%, 800px); |
| Fluid font size | Several media queries | font-size: clamp(...) |
The functions shine for properties that have no min- and max- variants, such as font-size, padding, margin, gap and border-radius. For width and height, min-width and max-width remain clear and perfectly fine.
clamp() arguments in the wrong order. The minimum must come first and the maximum last. If the minimum is larger than the maximum, the minimum wins.+ and -. clamp(1rem, 1rem+3vw, 3rem) is invalid.vw for the preferred value in text, which ignores user settings.min(10, 5px).min(), max() and clamp() are supported in all current browsers, including Chrome, Edge, Firefox and Safari, and have been since 2020. No fallback is needed for modern projects. If you still support a very old browser, write a plain font-size declaration before the clamp line.
width: min(90%, 1100px) and width: 90%; max-width: 1100px give the same result for width. The function form also works on properties that have no max variant.
Yes. It works for any numeric value: width, height, padding, margin, gap, border radius and more.
The preferred value is probably pure vw. Add a rem part such as 1rem + 3vw and use rem bounds so the text responds to zoom and font settings.
Yes. You can nest them and mix them with arithmetic, for example clamp(1rem, max(2vw, 1rem), 2rem), though simple forms are easier to read.
min() caps a value, max() sets a floor and clamp() does both around a preferred value. They accept mixed units and math without calc(), and they replace many media queries for fluid sizes. For text, keep rem in the preferred value and bounds so zoom and user font settings keep working.