HTML meter Tag: Measurements with Examples

html meter tag

Purpose and use cases: The HTML meter tag shows a scalar value within a known range.

You can use it for:

  • Stats
  • Progress levels
  • Scores
  • Resource usage

Understand the <meter> Tag in HTML

The <meter> tag displays a value on a fixed scale. It shows where the value sits in the range. It works well for scores, battery levels, disk space, or benchmarks.

The syntax looks like this:

<meter value="X" min="Y" max="Z">Fallback text</meter>

It shows the visual level bar. The value must fall between the min and max.

Required and Optional Attributes:

Required:

  • value – Current value shown by the meter.

Optional:

  • min – Lowest limit of the scale.
  • max – Highest limit of the scale.
  • low, high, optimum – Ranges that affect color or status.
  • form – Links the meter to a form.

Here is a quick example:

<meter value="7" min="0" max="10">7 out of 10</meter>

This shows a bar that fills up to 70%. The value is 7 on a scale from 0 to 10. It renders a colored level inside the bar.

Use for these cases:

  • Show scores
  • Show battery or fuel levels
  • Show memory, storage, or usage

It updates the value dynamically with JavaScript:

<meter id="speed" min="0" max="100" value="30"></meter>
<script>
  document.getElementById("speed").value = 60;
</script>

This updates the meter to 60 from 30 in real time.

Attributes of the <meter> Tag in HTML

The value attribute:

This sets the current number. It must be between min and max.

The min and max attributes:

These set the full range. The browser compares the value to these bounds.

low – high – optimum:

These affect how the meter looks:

  • low defines a lower warning level.
  • high defines an upper warning level.
  • optimum defines the best value.

Here is the tag:

<meter value="40" min="0" max="100" low="20" high="80" optimum="50"></meter>

The browser can change the bar color if the value is outside the low or high range.

Form Attribute and Its Role:

Use form to link the meter to a specific form:

<form id="sysForm"></form>
<meter value="60" min="0" max="100" form="sysForm"></meter>

This allows the meter to act as a field inside a form.

Visual Representation and Browser Support

Browsers render as a horizontal bar. The bar fills based on the value. The style may vary across systems.

Modern browsers support it:

  • Chrome: Yes
  • Firefox: Yes
  • Safari: Yes
  • Edge: Yes

Old versions of IE do not support.

How to Style the <meter> Tag with CSS

You can style the meter with CSS. But some browsers limit style parts like the bar color. Use pseudo-elements or vendor prefixes when needed.

<style>
meter {
  width: 100%;
  height: 25px;
}
</style>

This sets the bar width and height.

<style>
meter::-webkit-meter-optimum-value {
  background: green;
}
meter::-webkit-meter-suboptimum-value {
  background: orange;
}
meter::-webkit-meter-even-less-good-value {
  background: red;
}
</style>

This changes the color based on value ranges. It works in Chrome and Safari.

Examples

CPU Load Meter:

<label for="cpu">CPU Load:</label>
<meter id="cpu" value="55" min="0" max="100">55%</meter>

This shows CPU usage. The value is 55 out of 100. It helps users see system load in real time.

Score Rate Meter:

<label for="score">Performance Score:</label>
<meter id="score" value="72" min="0" max="100" low="40" high="85" optimum="90"></meter>

This shows a performance score. The bar fills up to 72%. The color can change if it drops below 40 or rises above 85.

Disk Space Usage:

<label for="disk">Disk Space Used:</label>
<meter id="disk" value="80" min="0" max="100">80%</meter>

This tracks disk space. It shows how full the drive is. The bar fills to 80% of the full range.

Live Update via JavaScript:

<label for="speed">Speed:</label>
<meter id="speed" min="0" max="200" value="90"></meter>
<script>
  setTimeout(() => {
    document.getElementById("speed").value = 120;
  }, 2000);
</script>

This changes the value after 2 seconds. It updates the meter from 90 to 120. It shows how to control the meter with code.

Wrapping Up

In this article, you learned what the HTML <meter> tag does and how it works. You also saw how to use its attributes and update it with JavaScript.

Here is a quick recap:

  • Use to show a value on a scale.
  • Use value, min, max, low, high, optimum, and form to control behavior.
  • Style it with basic or WebKit-specific CSS.
  • Update values with JavaScript.

What is the use of <meter> tag in HTML?

The <meter> tag represents a scalar value within a known range, such as disk usage or health bar levels. It is useful for showing measurable data like scores, progress, or storage space in a visual format. Example:
<label for="disk">Disk usage:</label>
<meter id="disk" value="70" min="0" max="100">70%</meter>

How is <meter> different from <progress> in HTML?

The <meter> tag is used for known ranges (e.g., score, temperature), while <progress> shows an indeterminate or ongoing task (like file upload). Example of <meter>:
<meter value="6" min="0" max="10"></meter>
Example of <progress>:
<progress value="50" max="100"></progress>

What are the common attributes of <meter> in HTML?

Common attributes of the <meter> tag include:
  • value – The current numeric value
  • min – The minimum value
  • max – The maximum value
  • low – A lower bound of the range
  • high – An upper bound of the range
  • optimum – The ideal value
Example:
<meter value="6" min="0" max="10" low="2" high="8" optimum="7"></meter>

Can I style the <meter> tag with CSS?

Yes, you can style the <meter> element using CSS, but customization is limited across browsers. Example:

<style>
  meter {
    width: 100px;
    height: 20px;
  }
</style>

<meter value="60" min="0" max="100"></meter>

Similar Reads

HTML Class Attribute: Use in CSS and JavaScript

The HTML class attribute helps group elements. It helps you update the page style without changing the structure of HTML.…

HTML embed Tag: How to Embed External Media in Web Pages

The HTML embed tag is used to display media content, such as videos or audio. It can also display PDFs…

HTML Mark Tag: How to Highlight Text

The mark tag highlights text in HTML and shows that the text has relevance in the content. It adds a…

HTML style Tag: Inline CSS

The style tag in HTML defines CSS inside a web page. Click to see how it works with syntax and…

HTML5 New Elements with Examples

HTML5 gave the web new elements that describe content with more meaning. Developers now use these elements to build pages…

How to Open Link in New Tab with HTML Target

This article shows you how to open a link in a new tab. Read the code and follow the examples…

Comments in HTML: How They Work with Examples

Comments in HTML help you explain your code. You can add notes without showing anything in the browser. Understand How…

HTML Document Structure: How to Create DOCTYPE in HTML

The DOCTYPE ensures that your HTML is readable by browsers and ensures that pages follow modern standards. Understand the DOCTYPE…

HTML iframe Tag: How to Embed Content with Examples

The iframe tag embeds another HTML page inside the current page. It loads content from a separate source. Understand the…

HTML br Tag: Line Breaks

The br tag adds a single line break in HTML. It is an empty tag that does not need a…

Previous Article

HTML tabindex Attribute: How it Works with Examples

Next Article

HTML template Tag: How it Works with Examples

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *


Subscribe to Get Updates

Get the latest updates on Coding, Database, and Algorithms straight to your inbox.
No spam. Unsubscribe anytime.