CSS: clamp()
What is clamp()
clamp() is a CSS math function that restricts a value to a range between a minimum and a maximum.
it is used for dynamic sizing (responsive design)
Syntax
clamp(min, x, max)
- if x is between min max, x is used.
- if x ≻ max, max is used.
- if x ≺ min, min is used.
Example
font-size: clamp(1rem, 2.5vw, 2rem);
width: clamp(200px, 50%, 600px);
browser support
supported by all major browsers since 2021.
CSS special property and values
- CSS: Length Units
- CSS: Angle Units (deg rad grad turn)
- CSS: variable (custom property)
- CSS: calc()
- CSS: clamp()
- CSS: inherit, initial, reset, revert, revert-layer
- CSS: all (reset, revert, default)
- CSS: initial value
- CSS: Property inheritance
- CSS: Computed Style
- CSS: Browser Default Style Sheet (2025-12)