W3cubDocs

/Web APIs

Document: hidden property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

The Document.hidden read-only property returns a Boolean value indicating if the page is considered hidden or not.

The Document.visibilityState property provides an alternative way to determine whether the page is hidden.

Value

A Boolean value, true if the page is hidden, and false otherwise.

Examples

document.addEventListener("visibilitychange", () => {
  console.log(document.hidden);
  // Modify behavior…
});

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
hidden 3313 12
18Since Firefox 56 it also returns true on macOS when the window is completely hidden by another non-translucent application.
10–52
12.1 7 3318
18Since Firefox for Android 56 it also returns true on macOS when the window is completely hidden by another non-translucent application.
10–52
12.1 7 2.01.0 4.4.34.4 7

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Document/hidden