HTML Progress & Meter
In this page:
<progress value="current" max="total"></progress>
<meter value="current" min="min" max="max"></meter>
The <progress> Element
The <progress> element displays a bar that fills up to show how much of a task has been completed. It takes a value attribute for the current amount and a max attribute for the total amount needed.
- Leave off the value attribute entirely to show an indeterminate, animated progress bar while a task's duration is unknown.
- Accepted attributes:
- value — number between 0 and max
- max — number greater than 0 (default 1)
- Omit value for an indeterminate bar
Example: The <progress> Element
<progress value="70" max="100"></progress>
Styling and Updating Progress Dynamically
The <progress> element can be restyled with CSS and its value can be changed at any time using JavaScript, letting you tie the bar directly to a real task like a file upload or a multi-step wizard.
Example: Styling and Updating Progress Dynamically
<progress id="bar" value="30" max="100"></progress>
<script>
document.getElementById('bar').value = 60;
</script>
The <meter> Element
The <meter> element displays a gauge for a known, fixed-range value, such as disk space used or a survey rating. Unlike <progress>, it is meant for measurements rather than ongoing task completion.
- Use <meter> for any value that has a defined minimum and maximum, even if that value never changes.
- Accepted attributes:
- value — current number
- min — lower bound (default 0)
- max — upper bound (default 1)
- low — upper limit of the low range
- high — lower limit of the high range
- optimum — the best value
Example: The <meter> Element
<meter value="0.6" min="0" max="1">60%</meter>
Meter Ranges: Low, High, and Optimum
The <meter> element accepts low, high, and optimum attributes, which let the browser color the gauge differently depending on whether the current value falls in a good, acceptable, or poor range.
- Set optimum close to whichever end of the range represents the best outcome, so browsers can color the gauge meaningfully.
- Accepted attributes:
- low — upper limit of the low range
- high — lower limit of the high range
- optimum — the ideal value
- min <= low <= high <= max
Example: Meter Ranges: Low, High, and Optimum
<meter value="80" min="0" max="100" low="33" high="66" optimum="100"></meter>
Progress vs Meter: When to Use Each
Choosing between <progress> and <meter> comes down to what the value represents: use <progress> for a task moving toward completion, and <meter> for a static measurement within a known range.
Example: Progress vs Meter: When to Use Each
<progress value="50" max="100"></progress>
<meter value="7" min="0" max="10"></meter>
- Using <progress> to display a static score or rating, when <meter> is the correct element for a fixed-range value.
- Forgetting to update the value attribute with JavaScript, leaving the progress bar frozen even as the real task continues.
- Omitting the max attribute on <progress>, which defaults to 1 and can make percentages calculate incorrectly.
- The <progress> element visually represents how far a task has advanced toward completion.
- The <meter> element visually represents a static value inside a known minimum and maximum range.
- Both elements can be updated dynamically with JavaScript by changing their value attribute.
Both <progress> and <meter> are supported natively in every modern browser.
Chapter Quiz — Complete all 20 topics to unlock
0/20 topics done
Complete these topics first:
- HTML Keyboard Shortcuts
- HTML Browser Support
- HTML Character Sets
- HTML Doctypes
- HTML Audio/Video Reference
- HTML Meta Tags
- HTML ARIA Roles
- HTML Input Validation
- HTML Iframe Security
- HTML Responsive Images
- HTML Web Fonts
- HTML Icon Fonts
- HTML Progress & Meter
- HTML Output Element
- HTML Datalist
- HTML Image Maps
- HTML Browser DevTools
- HTML Validation
- HTML Quiz
- HTML Interview Prep