A style attribute on a <meter> tag assigns a unique style to the meter control.
Its value is CSS that defines the appearance of the meter.
A style attribute on a <meter> element.
<div>Approving card...</div>
<br />
<meter value="0.35" style="width:180px;height:25px;">35%</meter>
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.
<meter style="CSS-styles">
Value | Description |
---|---|
CSS-styles | One or more CSS property/value pairs separated by semicolons (;). |
A style attribute on a <meter> element.
Clicking the button toggles the width of the element.
<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>
The style attribute assigns a width to the <meter> element.
Clicking the button calls JavaScript which toggles the element width.
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 |
Back to <meter>