HTML hidden Attribute

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The hidden global attribute tells the browser not to present an element’s contents. Use it when content is not relevant yet—for example a panel that appears after a step completes.

Modern HTML treats hidden as an enumerated attribute: the default hidden state, or until-found for content that stays searchable. It is not the same as <input type="hidden">, which still submits form data.

Baseline · Widely available.

The default hidden state is stable across modern browsers since about July 2015. Not deprecated.

Limited availability — until-found.

hidden="until-found" works in Chromium and newer Firefox, but not Safari. Treat it as progressive enhancement.

HTML Syntax

syntax.html
<element hidden [="hidden|until-found"]>

Works on any HTML element. An empty value or the keyword hidden means fully hidden; until-found means hidden until search or fragment navigation finds it.

Attribute Values

Valid keywords and common patterns:

ValueDescriptionTry it
hidden / emptyHidden state — not shown; usually display: noneTry it
until-foundHidden until Find in page or a fragment link reveals itTry it
Invalid valueStill treated as hidden (e.g. hidden="false")Try it
Attribute removedElement is shown again (or set element.hidden = false)Try it

Live Preview

Toggle the hidden attribute on a panel. Watch both the markup state and the visible result.

Panel

Uses the real hidden attribute (not CSS display).

Result

This panel is currently visible. Toggle to add or remove hidden.

Panel is shown (no hidden attribute).

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Hide Content by Default

Add hidden when a block is not relevant yet. It stays in the DOM but is not presented.

HTML
<p>This paragraph is visible.</p>

<p hidden>
  This paragraph is hidden until you remove the attribute.
</p>
Try It Yourself

How It Works

  1. Add the attribute. hidden (or hidden="" / hidden="hidden") marks the element as not relevant.
  2. Browser hides it. User-agent styles typically map this to display: none.
  3. Still in the DOM. Scripts can read or update the node even while it is hidden.
  4. Show later. Remove the attribute when the content becomes relevant.

Example 2 — Toggle with JavaScript

Flip visibility with the reflected element.hidden property.

HTML
<button type="button" id="toggleBtn">Toggle details</button>

<p id="details">Extra details are visible.</p>

<script>
  document.getElementById("toggleBtn").addEventListener("click", function () {
    var el = document.getElementById("details");
    el.hidden = !el.hidden;
  });
</script>
Try It Yourself

How It Works

  1. Start visible. The paragraph has no hidden attribute at first.
  2. Read/write hidden. el.hidden = true adds the attribute; false removes it.
  3. Toggle with !. el.hidden = !el.hidden flips the current state.
  4. Prefer the attribute. Do not leave hidden in place and override it with CSS display.

Example 3 — hidden="until-found"

Keep a section collapsed but revealable via Find in page or a fragment link (where supported).

HTML
<p><a href="#extra">Jump to hidden section</a></p>

<section id="extra" hidden="until-found">
  <h2>Extra notes</h2>
  <p>This section can be revealed by the fragment link or Find in page.</p>
</section>
Try It Yourself

How It Works

  1. Use until-found. Content is not shown, but Find in page / fragment navigation can still match it.
  2. On a match. Supporting browsers fire beforematch, remove hidden, and scroll to the element.
  3. Layout differs. Unlike plain hidden, until-found often keeps a box (via content-visibility: hidden).
  4. Check support. Not available in Safari yet — provide a non-critical enhancement only.

Edge Cases & Pitfalls

Most bugs come from treating hidden like CSS-only visibility or like type="hidden".

boolean trap

hidden="false" still hides

Only remove the attribute (or set element.hidden = false) to show content. Invalid values stay in the hidden state.

css

Do not override with display

A CSS display: block can make a still-hidden element appear. Remove hidden instead of fighting the UA style.

a11y

Hidden from everyone

Do not use hidden to hide content from only one presentation. Screen readers also skip the default hidden state.

links

Do not link to plain hidden content

Linking to a normally hidden section is incorrect. Use until-found when fragment navigation should reveal it.

scripts

Descendants stay active

Scripts inside a hidden tree can still run, and nested form controls can still submit. Hiding is presentation, not a sandbox.

Browser Support

hidden is an HTML global attribute in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

hidden

Default hidden state is widely available since about July 2015. The until-found value is limited (Chromium/Firefox; not Safari).

97% Global support (default state)
Google Chrome All · until-found 102+
Full support
Mozilla Firefox All · until-found 148+
Full support
Apple Safari All · until-found: no
Partial
Microsoft Edge All · until-found 102+
Full support
Opera All · until-found 88+
Full support
Samsung Internet Modern · until-found 19+
Full support
Internet Explorer 11 (default state)
Supported
hidden Widely supported

Bottom line: Safe to use the default hidden state everywhere. Use until-found only as an enhancement where Safari support is not required.

Key Takeaways

  • Role: mark content that is not currently relevant to present.
  • Values: empty/hidden for full hide; until-found for searchable hide.
  • Toggle: use element.hidden or add/remove the attribute — not hidden="false".
  • Not the same as <input type="hidden">.

One line: hidden means “not relevant to show now” — remove it when the content matters again.

Frequently Asked Questions

It marks content that should not be presented to the user right now. In the default hidden state, browsers typically apply display:none so the element is removed from layout and from assistive tech presentation.
Historically it was treated as boolean. In modern HTML it is enumerated: empty/hidden for the hidden state, or until-found for the hidden-until-found state. Invalid values still hide the element.
No. Presence of a non–until-found value (including false or bananas) still puts the element in the hidden state. Remove the attribute or set element.hidden = false in JavaScript to show it.
It hides content but keeps it findable via Find in page or fragment links. On a match, the browser fires beforematch, removes hidden, and scrolls to the element. Support is limited (not Safari).
No. The hidden attribute hides any element from presentation. input type="hidden" is a form control that still submits a value with the form.
Yes. Setting display to something other than none (for example display:block) can show an element that still has hidden. Prefer removing the attribute instead of fighting it with CSS.

Next: high

Mark the high range on a meter element.

high tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful