A hidden attribute on a <textarea> tag hides the textarea.
Although the textarea is not visible, its position on the page is maintained.
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>
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.
<textarea hidden>
<textarea hidden="hidden">
Value | Description |
---|---|
hidden | Use 'hidden' or hidden='hidden'. Both are valid. |
Clicking the button toggles A 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>
Initially, the <textarea> is visible.
Clicking the button calls JavaScript that toggles the hidden attribute.
With the hidden attribute the textarea is invisible.
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 |