HTML <figure> hidden Attribute

The hidden attribute on a <figure> tag hides that figure. Althought the figure is not visible, its position on the page is maintained.

Example

#

A hidden attribute on an <figure>.
The figure is not visible.

An invisible figure:

<p>An invisible figure:</p>

<figure hidden>
  <img src="/img/html/sangiorgio.jpg">
</figure>

Using hidden

The hidden attribute hides the <figure> element.

You can specify either 'hidden' (without value) or 'hidden="hidden"'. Both are valid.

A hidden <figure> is not visible, but maintains its position on the page.


Syntax

<figure hidden>
or
<figure hidden="hidden">

Values

#

Value Description
hidden Use value 'hidden' or no value at all.

More Examples

Clicking the button toggles the hidden attribute on the <figure> element.


<figure id="myfigure">
  <img src="/img/html/sangiorgio.jpg">
</figure>

<br />
<button onclick="toggle(this)">Hide figure</button>

<script>
  let toggle = button => {
    let element = document.getElementById("myfigure");
    let hidden = element.getAttribute("hidden");

    if (hidden) {
       element.removeAttribute("hidden");
       button.innerText = "Hide figure";
    } else {
       element.setAttribute("hidden", "hidden");
       button.innerText = "Show figure";
    }
  }
</script>

Code explanation

Initially the <figure> element has no hidden attribute and is visible.

Clicking the button invokes a JavaScript which toggles the hidden attribute on the <figure>.


Browser support

Here is when hidden support started for each browser:

Chrome
6.0 Sep 2010
Firefox
4.0 Mar 2011
IE/Edge
9.0 Mar 2011
Opera
11.1 Mar 2011
Safari
5.0 Jun 2010

You may also like

 Back to <figure>
Guides