progress() CSS Function
The progress() function returns a number from 0 to 1 that shows how far a value lies between a start and an end value.
Description
The progress() CSS function returns a number that shows how far a value lies between a start value and an end value. If the value equals the start, the result is 0; if it equals the end, the result is 1; halfway between gives 0.5. The result is clamped to the range 0 to 1, so values outside the range return 0 or 1.
All three arguments must resolve to the same type, such as three lengths or three numbers, but the result is always a plain <number>. That lets you convert one kind of value into another: for example, turning the current viewport width into a 0 to 1 factor and then using it for opacity, a color mix or a font size. It is the reverse of interpolating between two values, and it works well together with calc() and color-mix().
/* Fade in a sidebar as the viewport grows from 600px to 1200px */
.sidebar {
opacity: progress(100vw, 600px, 1200px);
}
/* Fill a meter based on a value between a minimum and maximum */
.meter-fill {
width: calc(progress(var(--value), var(--min), var(--max)) * 100%);
}
/* Fluid font size between 16px and 24px */
p {
font-size: calc(16px + 8px * progress(100vw, 400px, 1200px));
}
Interactive Demo
Syntax
progress() = progress( <calc-sum>, <calc-sum>, <calc-sum> )
Values
- valueA calculation resolving to a <number>, <dimension> or <percentage>: the value to measure.
- startA calculation of the same type: the value that corresponds to 0.
- endA calculation of the same type: the value that corresponds to 1. The result is a <number> clamped between 0 and 1.
Example
Browser Support
The following information will show you the current browser support for the CSS progress() function. Hover over a browser icon to see the version that first introduced support for this CSS function.
Desktop





Tablets & Mobile





