Open In App

What is the Purpose of the Hidden Attribute in HTML?

Last Updated : 19 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The hidden attribute in HTML is used to indicate that an element is not yet, or is no longer, relevant or needed for the user interface. It effectively hides the element from view but does not remove it from the document structure.

Note: The hidden attribute is a boolean attribute, meaning its presence alone is sufficient, and it doesn’t require a value.

Syntax:

<!-- Hiding an element using the hidden attribute -->
<div hidden>
This content is hidden.
</div>

<!-- Hiding a form input using the hidden attribute -->
<input type="text" hidden>

Features:

The hidden Attribute also:

  • Hides the associated element from the user interface.
  • The element remains in the document structure but is not rendered or displayed.
  • Can be applied to various HTML elements, such as <div>, <span>, or form elements.
  • While hidden hides the element visually, it doesn’t necessarily make it inaccessible to assistive technologies. Use CSS in conjunction with hidden to ensure appropriate accessibility.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads