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 Element: Everything You Need To Know with Examples

An HTML element builds every part of a web page. It holds the text or block you want the browser…

HTML Syntax for Beginners: How it Works with Examples

HTML syntax shows how tags and attributes go together. It gives browsers the rules to read and display a page.…

HTML Textarea Tag: How it Works with Examples

The HTML textarea tag gives users space to enter longer messages. This element helps build forms that accept feedback, comments,…

HTML figure Tag: Responsive Design & Media Elements

The HTML figure tag links media with a caption. Use it to group an image, diagram, code block, or video…

HTML a Tag: How to Add Links to Web Page with Examples

The HTML a tag allows you to create links that move users from one page or resource to another. Understand…

HTML Global Attributes Overview

HTML global attributes work on most elements. They do not depend on the tag name. You can use them with…

HTML output Tag: How to Display Calculation Results

The <output> tag in HTML shows results inside a form. It helps display values from user actions or scripts. You…

HTML List Tag: Understand the ul, ol, and dl Lists

HTML has three main list tags: <ul>, <ol>, and <dl>. Each one shows a different kind of group. In this…

HTML Form novalidate Attribute: How it Works with Examples

The form novalidate attribute in HTML lets you skip browser checks when you submit a form. You can control errors…

HTML abbr Tag: How Abbreviations Work with Examples

The abbr tag refers to an abbreviation in HTML. It helps you save space and improve accessibility. The screen readers…

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.