Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest self-service freelancing marketplace for people like you.

HTML <iframe> hidden Attribute

A hidden attribute on an <iframe> tag hides the iframe.

Although the iframe is not visible, its position on the page is maintained.

Example

#

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

A hidden iframe:

<p>A hidden iframe:</p>

<iframe src="https://en.wikipedia.org" style="width:100%;" hidden>
</iframe>

Using hidden

The hidden attribute hides the <iframe> element.

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

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


Syntax

<iframe hidden>
or
<iframe hidden="hidden">

Values

#

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

More Examples

Clicking the button toggles A hidden attribute on the <iframe> element.



<iframe id="myiframe" src="https://en.wikipedia.org" style="height:450px;width:100%;"></iframe>

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

<script>
  let toggle = button => {
    let element = document.getElementById("myiframe");
    let hidden = element.getAttribute("hidden");
    
    if (hidden) {
       element.removeAttribute("hidden");
       button.innerText = "Hide Iframe";
    } else {
       element.setAttribute("hidden", "hidden");
       button.innerText = "Show Iframe";
    }
  }
</script>

Code explanation

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

Clicking the button calls JavaScript that toggles A hidden attribute on the <iframe>.

The hidden attribute hides the <iframe> element.


Browser support

Here is when hidden support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <iframe>
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest self-service freelancing marketplace for people like you.

Guides