Favorites

progress() CSS Function

progress()
CSS FunctionThis function is supported by all modern browsers.
Updated 21st November 2026

The progress() function returns a number from 0 to 1 that shows how far a value lies between a start and an end value.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

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

050px100px150px200px250px
Demo Code
HTML Code
<div class="demo-track">
	<div class="demo-element"></div>
</div>
<div class="demo-scale"><span>0</span><span>50px</span><span>100px</span><span>150px</span><span>200px</span><span>250px</span></div>
CSS Code
.demo-track {
	width: 300px;
	height: 36px;
	background: #f4f4f4 repeating-linear-gradient(90deg, #b0b0b0 0 1px, transparent 1px 50px);
	outline: 1px solid #c5c5c5;
}
.demo-scale {
	display: grid;
	grid-template-columns: repeat(6, 50px);
	width: 300px;
	font-size: 11px;
	color: #666;
}
.demo-element {
	height: 100%;
	background: linear-gradient(90deg, #f72585, #b5179e);
	width: calc(progress(150px, 0px, 300px) * 300px);
}

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

<div class="wrap">
<h1>CSS progress() examples</h1>
<div class="card list">
<div class="track"><div class="fill" style="--value: 70px"></div></div><div class="label">progress(70px, 20px, 220px) = 0.25</div>
<div class="track"><div class="fill" style="--value: 120px"></div></div><div class="label">progress(120px, 20px, 220px) = 0.5</div>
<div class="track"><div class="fill" style="--value: 190px"></div></div><div class="label">progress(190px, 20px, 220px) = 0.85</div>
<div class="track"><div class="fill" style="--value: 400px"></div></div><div class="label">progress(400px, 20px, 220px) = 1 (clamped)</div>
</div>
</div>
/* Base demo layout */
* { box-sizing: border-box; }

body {
margin: 24px;
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
background: #f5f7fb;
color: #102a43;
}

.wrap {
max-width: 860px;
margin: 0 auto;
}

h1 {
font-size: 20px;
margin: 0 0 16px;
}

.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 16px;
}

.card {
background: #fff;
border-radius: 12px;
padding: 16px;
box-shadow: 0 6px 18px rgba(16, 42, 67, 0.08);
}

.label {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
font-size: 12px;
color: #486581;
margin-top: 10px;
word-break: break-word;
}

.note {
font-size: 13px;
color: #486581;
margin-top: 14px;
}

/* progress() examples */
.bar {
height: 28px;
border-radius: 6px;
background: linear-gradient(90deg, #2563eb, #06b6d4);
max-width: 100%;
}

.track {
background: #e2e8f0;
border-radius: 6px;
overflow: hidden;
}

.list { display: grid; gap: 10px; }
.track { height: 28px; }
.fill {
height: 100%;
width: calc(progress(var(--value), 20px, 220px) * 100%);
background: linear-gradient(90deg, #16a34a, #84cc16);
}
Open in editor

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.

This function is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.