HTML <a> hidden Attribute

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

Example

#

A hidden attribute on an <a> tag.
The link is not visible.

An invisible link:

<p>
  An invisible link: 
  <a hidden target="_blank" 
     href="https://microsoft.com">Microsoft</a>
</p>

Using hidden

The hidden attribute hides the <a> element.

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

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

Removing the hidden attribute makes it re-appear.


Syntax

<a hidden>
or
<a hidden="hidden">

Values

#

Value Description
hidden Use 'hidden' or hidden='hidden'. Both are valid.

More Examples

Clicking the button toggles the hidden attribute on the link to Apple.

<nav>
 <a id="msft" target="_blank" href="https://microsoft.com">Microsoft</a> <br />
 <a id="goog" target="_blank" href="https://google.com">Google</a> <br />
 <a id="aapl" target="_blank" href="https://apple.com">Apple</a> 
<nav>

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

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

Code explanation

The hidden attribute hides the <a> element.

When clicking the button, a JavaScript function toggles the hidden attribute.


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 <a>
Guides