HTML <meter> style Attribute

The style attribute on a <meter> tag assigns a unique style to the meter control. A style contains one or more CSS property/value pairs that define the appearance of the meter.

Example

#

A style attribute on a <meter> element.

Approving card...

35%
<div>Approving card...</div>

<br />
<meter value="0.35" style="width:180px;height:25px;">35%</meter>

Using style

The style attribute specifies the style, i.e. look and feel, of the <meter> element.

A style contains any number of CSS property/value pairs, separated by semicolons (;).

The style attribute overrides any other style that was defined in a <style> tag or an external CSS file.

This inline styling affects the current <meter> element only.


Syntax

<meter style="CSS-styles">

Values

#

Value Description
CSS-styles One or more CSS property/value pairs separated by semicolons (;).

More Examples

A style attribute on a <meter> element.
Clicking the button toggles the width of the element.

Loading files...

35%

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

<br />
<meter id="mymeter" value="0.35" style="width:180px;height:25px;">35%</meter>

<br /><br />
<button onclick="toggle();">Toggle style</button>

<script>
  let toggle = () => {
    let element = document.getElementById("mymeter");

    if (element.style.width === "180px") {
       element.style.width = "280px";

    } else {
       element.style.width = "180px";
    }
  }
</script>

Code explanation

The style attribute assigns a width to the <meter> element.

Clicking the button calls JavaScript which toggles the element width.


Browser support

Here is when style support started for each browser:

Chrome
8.0 Dec 2010
Firefox
6.0 Aug 2011
IE/Edge
13.0 Nov 2015
Opera
11.0 Dec 2010
Safari
6.0 Jul 2012

You may also like

 Back to <meter>
Guides