Skip to main content

HTML Tags

HTML <meter> Tag

Written by Updated HTML <meter> Tag exercises

The meter tag shows a measurement within a known range as a small gauge: battery level, disk space used, a test score, password strength. With low, high and optimum, the browser can even color it green, yellow or red.

A meter is not a progress bar. For "how far along is this task", like a file upload, use the progress tag. A meter shows a value that just is, like 65% battery.

Syntax

html

<meter value="current" min="minValue" max="maxValue" low="lowValue" high="highValue" optimum="optimumValue">
  Fallback text
</meter>

Attributes

AttributeWhat it does
valueThe current value. Required.
minThe lowest possible value. Default 0.
maxThe highest possible value. Default 1, so set it.
lowValues below this count as "low".
highValues above this count as "high".
optimumThe best value. It tells the browser whether low or high is good.

Example

html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Meter Tag Example</title>
</head>
<body>
  <h2>Battery Level</h2>
  <label for="battery">Battery:</label>
  <meter id="battery" value="65" min="0" max="100" low="20" high="80" optimum="90">
    65%
  </meter>
  <p>The battery level is at 65%.</p>
</body>
</html>

A gauge shows 65 out of 100. Because optimum is 90, high values are good; 65 sits in the middle range, so most browsers color it yellow. Try changing value to 15 or 95 to see the color change.

How the colors are chosen

The browser compares the value with low, high and optimum. If the value is in the same region as the optimum, it is green; one region away, yellow; two regions away, red. For disk space, where low is good, set optimum to a small number and the colors flip.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

Good to know

  • Always put a label next to it and the value in text inside it, like <meter value="0.65">65%</meter>. Screen readers and old browsers use that text.
  • Default meters look different in every browser. Styling them consistently needs browser-specific pseudo-elements, so many sites draw their own bar with a div and keep <meter> for simple cases.

HTML <meter> Tag exercises

Show a measurement

Show a measurement of 6 on a scale from 0 to 10. Its text for browsers that cannot draw it is 6 out of 10.

Result

Check your answer to see it here.