HTML <textarea> hidden Attribute

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

Example

#

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

A hidden textarea:

<p>A hidden textarea:</p>

<textarea rows="6" cols="75" hidden>
  Rembrandt van Rijn was a Dutch draughtsman, painter, and printmaker. 
  An innovative and prolific master in three media, he is generally 
  considered one of the greatest visual artists in the history of
  art and the most important in Dutch art history.
</textarea>

Using hidden

The hidden attribute hides the <textarea> element.

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

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

Removing the hidden attribute makes it re-appear.


Syntax

<textarea hidden>
or
<textarea 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 <textarea>.


<textarea id="mytextarea" rows="6" cols="75">
  Rembrandt van Rijn was a Dutch draughtsman, painter, and printmaker. 
  An innovative and prolific master in three media, he is generally 
  considered one of the greatest visual artists in the history of
  art and the most important in Dutch art history.
</textarea>

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

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

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

Code explanation

Initially, the <textarea> is visible.

Clicking the button calls JavaScript that toggles the hidden attribute.

With the hidden attribute the textarea is invisible.


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