The <progress>
tag is an HTML5 element used to represent the progress of a task such as downloading, uploading, or completing a process. It provides a native, accessible way to show a progress bar in your web page.
📌 What Is the <progress>
Tag?
- The
<progress>
element displays a progress bar. - It can show determinate progress (with a known value) or indeterminate progress (when the amount of work is unknown).
- It is a void element (can have an opening and closing tag, but no content inside).
- Supported in all modern browsers.
✅ Basic Syntax
<progress value="30" max="100"></progress>
value
: Current progress (number).max
: Maximum value of the task (default is 1 if omitted).
🧩 Structure Diagram
<progress value="current" max="maximum"></progress>
🧪 Example 1: Determinate Progress Bar
<label for="file">File download progress:</label>
<progress id="file" value="45" max="100">45%</progress>
This displays a progress bar filled 45% to indicate how much of the task is completed.
🧪 Example 2: Indeterminate Progress Bar
<label>Loading, please wait...</label>
<progress></progress>
Without the value
attribute, the bar shows an animated indicator meaning progress is ongoing but undefined.
💡 Attributes of <progress>
Attribute | Description |
---|---|
value | Current progress (number ≤ max) |
max | Total amount representing 100% completion (default 1) |
🛠️ Dynamic Example: JavaScript Updating Progress
<progress id="progressBar" value="0" max="100"></progress>
<button onclick="startProgress()">Start</button>
<script>
function startProgress() {
let progress = 0;
const bar = document.getElementById('progressBar');
const interval = setInterval(() => {
progress += 10;
bar.value = progress;
if (progress >= bar.max) clearInterval(interval);
}, 500);
}
</script>
Clicking the button starts increasing the progress bar by 10% every half second until it reaches 100%.
♿ Accessibility Considerations
<progress>
is accessible by default to screen readers.- Using the
label
element linked to<progress>
improves usability. - Always provide a visible text fallback inside the
<progress>
tag for older browsers.
🎨 Styling the <progress>
Bar
Default styling is browser-dependent, but you can customize with CSS:
progress {
width: 300px;
height: 20px;
appearance: none;
}
progress::-webkit-progress-bar {
background-color: #eee;
border-radius: 10px;
}
progress::-webkit-progress-value {
background-color: #76c7c0;
border-radius: 10px;
}
progress::-moz-progress-bar {
background-color: #76c7c0;
border-radius: 10px;
}
⚠️ Notes
- Not all CSS properties work on
<progress>
in all browsers — customization can be tricky. - For complex progress indicators, consider custom HTML/CSS + JavaScript.
🏁 Summary
The <progress>
tag is a simple, semantic way to show task progress on the web. It supports both determinate and indeterminate states and is accessible out of the box. Use it to improve user experience during long-running tasks.