A hidden attribute on a <meter> tag hides the meter element.
Although the meter is not visible, it maintains its position on the page.
A hidden attribute on a <meter> tag.
The meter element is not visible.
A hidden meter element:
<p>A hidden meter element:</dp>
<meter value="0.5" hidden>50%</meter>
The hidden attribute hides the <meter> element.
You can specify either 'hidden' (without value) or 'hidden="hidden"'. Both are valid.
A hidden <meter> element is not visible, but it maintains its position on the page.
Removing the hidden attribute makes it re-appear.
<meter hidden>
<meter hidden="hidden">
Value | Description |
---|---|
hidden | Use 'hidden' or hidden='hidden'. Both are valid. |
Clicking the button toggles A hidden attribute on the <meter> element.
<div>Loading files...</div>
<br />
<meter id="mymeter" value="0.5">50%</meter>
<br /><br />
<button onclick="toggle(this)">Hide meter</button>
<script>
let toggle = button => {
let element = document.getElementById("mymeter");
let hidden = element.getAttribute("hidden");
if (hidden) {
element.removeAttribute("hidden");
button.innerText = "Hide meter";
} else {
element.setAttribute("hidden", "hidden");
button.innerText = "Show meter";
}
}
</script>
Initially, the <meter> is visible and has no hidden attribute.
Clicking the button calls JavaScript which toggles the hidden attribute.
Here is when hidden 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 |