HTML <meter> id Attribute

An id on a <meter> tag assigns an identifier to the meter.

The identifier must be unique across the page.



An id attribute on a <meter> element.

Loading files...

<div>Loading files...</div>

<br />
<meter id="load-meter" value="0.5">50%</meter>

Using id

The id attribute assigns an identifier to the <meter> element.

The id allows JavaScript to easily access the <meter> element.

It is also used to point to a specific id selector in a style sheet.

Tip:  id is a global attribute that can be applied to any HTML element.


<meter id="identifier" />



Value Description
identifier A unique alphanumeric string. The id value must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens (-), underscores (_), colons (:), and periods (.).

More Examples

A <meter> element with a unique id.
Clicking the button displays the meter value.

Loading files...


<div>Loading files...</div>

<br />
<meter id="mymeter" value="0.35">35%</meter>

<br /><br />
<button onclick="show();">Show meter value</button>

  let show = () => {
    let element = document.getElementById("mymeter");
    alert("Value = " + element.value);

Code explanation

The id attribute assigns a unique identifier for the <meter>.

Clicking the button calls JavaScript which locates the <meter> using the id.

Finally, the <meter> value is displayed in an alert box.

Browser support

Here is when id support started for each browser:

8.0 Dec 2010
6.0 Aug 2011
13.0 Nov 2015
11.0 Dec 2010
6.0 Jul 2012

You may also like

 Back to <meter>

Author: Jack Poorte
Published: Jun 20 2021
Last Reviewed: Sep 30 2023

What's your favorite/least favorite part of Dofactory?