<meter>
A gauge for a value within a known range: disk space used, a test score, battery level.
- Display
- inline-block
- Closing tag
- Required
- Permitted content
- Phrasing content without other
<meter>elements
Example
#<p>
<label for="score">CSS test score</label>
<meter id="score" min="0" max="100" value="72">72 out of 100</meter>
72/100
</p>
<p>
<label for="disk">Space for projects</label>
<meter id="disk" value="0.8">80%</meter>
80% used
</p>Definition and usage
#The <meter> element shows a measurement within a given range, a bit like a car’s fuel gauge. You give a value (value) and the bounds (min and max), and the browser draws a bar filled in proportion to the result.
The low, high and optimum attributes split the range into zones and say which values are good. The browser then colors the bar: usually green when the value is in the optimal zone, yellow for an average value, and red when it’s bad.
Don’t confuse it with <progress>. <meter> shows a state (how much space files take up), while <progress> shows a task’s progress over time (how much of a file has uploaded so far). Just like a progress bar, <meter> needs a label.
Syntax
#<meter value="0.6">60%</meter>Attributes
#number
The measured value. It should fall betweenminandmax; the browser clamps values outside the range to the limits.number (0 and 1 by default)
The bounds of the range. They let you give values in natural units, for example test points from 0 to 40, or megabytes.number within the range
lowsets the upper bound of the low-value zone, andhighthe lower bound of the high-value zone. A value between them is average. In the example, the same battery gauge changes color depending on the zone.number within the range
The ideal value. If it lies in the high zone, high results are good (like battery charge), and if in the low zone, low results are good (like the number of bugs in code). The bar’s color depends on this.
The element also supports all global attributes, such as class, id, style and hidden.
Attributes in practice
#value
numberThe measured value. It should fall between min and max; the browser clamps values outside the range to the limits.
<p><meter value="0.25">25%</meter> 25%</p>
<p><meter value="0.5">50%</meter> 50%</p>
<p><meter value="0.9">90%</meter> 90%</p>min / max
number (0 and 1 by default)The bounds of the range. They let you give values in natural units, for example test points from 0 to 40, or megabytes.
<p>Quiz points: <meter min="0" max="40" value="31">31 of 40</meter> 31 of 40</p>low / high
number within the rangelow sets the upper bound of the low-value zone, and high the lower bound of the high-value zone. A value between them is average. In the example, the same battery gauge changes color depending on the zone.
<p>Battery 90% <meter min="0" max="100" low="20" high="80" optimum="100" value="90"></meter></p>
<p>Battery 50% <meter min="0" max="100" low="20" high="80" optimum="100" value="50"></meter></p>
<p>Battery 10% <meter min="0" max="100" low="20" high="80" optimum="100" value="10"></meter></p>optimum
number within the rangeThe ideal value. If it lies in the high zone, high results are good (like battery charge), and if in the low zone, low results are good (like the number of bugs in code). The bar’s color depends on this.
<p>Bugs in the code: 2 <meter min="0" max="20" low="5" high="10" optimum="0" value="2"></meter></p>
<p>Bugs in the code: 15 <meter min="0" max="20" low="5" high="10" optimum="0" value="15"></meter></p>Browser support
#Widely available
Works in all modern browsers, phones included. You can use it without worry.
- Chrome
- Edge
- Firefox
- Safari
Good practices
#- Color can’t be the only cue. Show a number or a description next to the gauge too, because not everyone can tell green from red.
- For progress bars (uploading, installing, finishing a course), use
<progress>, not<meter>.
Related entries
#- <progress>A progress bar for a task: uploading a file, an installation, or course completion.
- <output>The result of a calculation or a user action, for example a total in a calculator.
- <label>A form field’s label. Clicking the label moves the cursor to the field.
- <input>A form field: text, email, password, number, date, slider, checkbox, file and many more.
Spotted a mistake or missing an example? Write to us.