The hidden Attribute — HTML Technical Interview Questions & Answers

Hiding an element from rendering and accessibility trees.

The hidden Attribute

  • Hiding an element from rendering and accessibility trees.
  • The hidden Attribute is an HTML attribute — extra info on the opening tag. Example: class, id, href, src, alt, for, type. <p class="fail">Fail</p>
  • id is unique on the page. class can repeat. Don’t use the same id twice. Prefer class for CSS.
  • Trap: styling with id for everything. Trap: inline style when a class would do.

Technical Interview Tip: The hidden Attribute: show it on a tag. id vs class if relevant.

Code Examples for The hidden Attribute

The hidden Attribute — working example

<section id="faq" class="panel panel--wide" data-topic="html">
  <h2>FAQ</h2>
  <p hidden>Screened until revealed</p>
  <p contenteditable="true">Editable note</p>
</section>

The hidden Attribute — id is unique; class is reusable; data-* stores custom values for CSS/JS hooks.

How to Explain The hidden Attribute to an Interviewer

What is The hidden Attribute?

An HTML attribute Goes on the opening tag