Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

HTMLElement.hidden — hiding an element

HTMLElement.hidden reflects the hidden attribute: it returns false, true, or "until-found". It is not a visibility test.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

element.hidden; element.hidden = true; element.hidden = false; element.hidden = "until-found";

HTMLElement.hidden reflects the hidden attribute. Reading returns false when absent, "until-found" for that state, otherwise true.

Assigning true hides; false removes the attribute. setAttribute("hidden", "false") still hides: an invalid value means Hidden.

"until-found" enables reveal through search or fragment navigation: the browser fires beforematch, then removes the attribute. This state requires browser support; borders and spacing may remain.

This is an HTML API, not ECMAScript. CSS can override its effect; the property does not measure visibility. Hiding also applies to assistive technology, but does not disable scripts or form-control submission.

Examples

(() => {
  const panel = document.createElement("div");
  console.log(panel.hidden);

  panel.hidden = true;
  console.log(panel.hidden, panel.hasAttribute("hidden"));

  panel.hidden = false;
  console.log(panel.hidden, panel.hasAttribute("hidden"));

  panel.setAttribute("hidden", "false");
  console.log(panel.hidden);
})();

Result

false
true true
false false
true

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources