The hidden Attribute
Toggle element visibility with the hidden boolean attribute.
What Is hidden?
The hidden attribute makes an element invisible and removes it from the accessibility tree:
<p hidden>This paragraph is hidden.</p>
<!-- Equivalent to: display: none in CSS -->
<!-- The element is in the DOM but not rendered -->
<!-- Screen readers do not announce hidden elements -->hidden Is a Boolean Attribute
Boolean attributes are either present (true) or absent (false) — no value needed:
<!-- All of these are equivalent: -->
<div hidden>Content</div>
<div hidden="">Content</div>
<div hidden="hidden">Content</div>
<!-- Remove with JavaScript: -->
element.removeAttribute('hidden');
<!-- Or set: -->
element.setAttribute('hidden', '');All lessons in this course
- id class style and title
- The hidden Attribute
- tabindex and accesskey
- Custom Data Attributes data-*