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 <input> hidden Attribute

A hidden attribute on an <input> tag hides the input element.

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

Example

#

A hidden attribute on an <input> element.
The text field is not visible.

A hidden input element:

<p>A hidden input element:</p>

<input type="text" hidden>

Using hidden

The hidden attribute hides the <input> element.

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

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


Syntax

<input hidden>
or
<input 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 <input> element.



<input id="myinput" type="text" placeholder="Enter your name...">

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

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

Code explanation

Initially, the <input> can be seen and has no hidden attribute.

Clicking the button calls JavaScript which toggles the hidden attribute from the <input> 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 <input>
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