JavaScript Document fullscreen Property

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Deprecated
Instance property

What You’ll Learn

Document.fullscreen is a deprecated instance property that returns true or false for fullscreen mode. Learn the no-op setter quirk, why fullscreenElement is better, how it fits the Fullscreen API, and five examples with try-it labs.

01

Kind

Read-only property

02

Type

boolean

03

Status

Deprecated

04

Means

Fullscreen on?

05

Replace

fullscreenElement

06

Setter

No-op ignored

Introduction

The Fullscreen API lets a page expand a video, game canvas, or gallery to fill the screen. Scripts often need a simple yes/no answer: “Are we in fullscreen right now?”

Historically, that answer was document.fullscreen. MDN now calls it obsolete and recommends checking Document.fullscreenElement instead—if it is not null, fullscreen mode is active.

💡
Boolean vs Element

fullscreen only says yes/no. fullscreenElement also tells you which element is fullscreen—more useful for UI state.

Related Document tutorials: fragmentDirective, forms, Document constructor.

Understanding Document.fullscreen

An obsolete read-only instance property on Document that reports whether fullscreen mode is active (MDN).

  • Valuetrue if an element is in fullscreen; otherwise false.
  • Read-only — meant for reading, not controlling fullscreen.
  • Lenient setter — assigning does not throw; the write is ignored (MDN).
  • Deprecated — prefer fullscreenElement !== null (MDN).
  • Related APIsrequestFullscreen, exitFullscreen, fullscreenEnabled.

📝 Syntax

JavaScript
document.fullscreen

Value

A Boolean: true if the document is displaying an element in fullscreen mode; otherwise false (MDN).

MDN modern replacement

JavaScript
function isDocumentInFullScreenMode() {
  return document.fullscreenElement !== null;
}

⚡ Quick Reference

GoalCode / note
Legacy checkdocument.fullscreen
Modern check (MDN)document.fullscreenElement !== null
Which element?document.fullscreenElement
Enter fullscreenel.requestFullscreen()
Exit fullscreendocument.exitFullscreen()
MDN statusDeprecated

🔍 At a Glance

Four facts about document.fullscreen.

Type
boolean

true / false

Access
read-only

Setter no-op

Status
deprecated

Obsolete

Prefer
fullscreenElement

Modern check

📋 fullscreen vs fullscreenElement

document.fullscreendocument.fullscreenElement
TypebooleanElement | null
Recommended?No (deprecated)Yes (MDN)
AnswersIs fullscreen on?Which element is fullscreen?
Active check=== true!== null

Examples Gallery

Examples follow MDN Document: fullscreen. Fullscreen toggles usually need a user gesture (button click).

📚 Getting Started

Compare the obsolete Boolean with the modern Element check.

Example 1 — MDN: Legacy document.fullscreen

Obsolete helper that returns the deprecated Boolean.

JavaScript
function isDocumentInFullScreenMode() {
  return document.fullscreen;
}

console.log("fullscreen?", isDocumentInFullScreenMode());
Try It Yourself

How It Works

Useful only for understanding old scripts. New code should not call this.

Example 2 — MDN: Prefer fullscreenElement

Same yes/no answer using the current API.

JavaScript
function isDocumentInFullScreenMode() {
  return document.fullscreenElement !== null;
}

console.log("fullscreen?", isDocumentInFullScreenMode());
console.log("element:", document.fullscreenElement);
Try It Yourself

How It Works

If fullscreenElement isn’t null, fullscreen mode is in effect (MDN).

📈 No-op Setter, Toggle & Events

See the ignored assignment, then control fullscreen with the modern API.

Example 3 — Assigning Does Not Throw (MDN)

The setter is a no-operation and is ignored—even in strict mode.

JavaScript
"use strict";
const before = document.fullscreen;
document.fullscreen = true; // ignored — does not enter fullscreen
const after = document.fullscreen;
console.log({ before, after, changed: before !== after });
Try It Yourself

How It Works

Never try to “turn on fullscreen” by assigning this property—use requestFullscreen().

Example 4 — Toggle Fullscreen (Modern API)

Enter/exit fullscreen from a button (user gesture required).

JavaScript
const box = document.getElementById("stage");

document.getElementById("toggle").addEventListener("click", async () => {
  try {
    if (!document.fullscreenElement) {
      await box.requestFullscreen();
    } else {
      await document.exitFullscreen();
    }
  } catch (err) {
    console.error(err);
  }
  // Prefer modern check:
  console.log("active?", document.fullscreenElement !== null);
  // Legacy (deprecated):
  console.log("legacy fullscreen?", document.fullscreen);
});
Try It Yourself

How It Works

Check document.fullscreenEnabled if you need to hide the toggle when fullscreen is blocked.

Example 5 — Listen for Fullscreen Changes

Update UI when the user presses Esc or your script exits fullscreen.

JavaScript
document.addEventListener("fullscreenchange", () => {
  const active = document.fullscreenElement !== null;
  console.log("fullscreenchange →", active);
  // Do not depend on document.fullscreen in new UI code
});

document.addEventListener("fullscreenerror", (event) => {
  console.error("fullscreenerror", event);
});
Try It Yourself

How It Works

Events keep button labels and CSS classes in sync without polling either property.

🚀 Common Use Cases

  • Legacy maintenance — recognize old if (document.fullscreen) checks.
  • Migration — replace with fullscreenElement !== null.
  • Teaching Fullscreen API — contrast Boolean vs Element APIs.
  • Not for new features — MDN: avoid using it; update existing code.
  • Video / games — toggle with requestFullscreen / exitFullscreen.
  • UI state — listen to fullscreenchange instead of polling.

🧠 Legacy Check vs Modern Check

1

User requests fullscreen

element.requestFullscreen() after a click/tap.

Enter
2

Browser sets fullscreen element

Document tracks which Element is on the top layer.

State
3

Legacy: document.fullscreen

Returns true/false (deprecated Boolean flag).

Obsolete
4

Modern: fullscreenElement !== null

Preferred check—also reveals which element is fullscreen.

📝 Notes

  • MDN: Deprecated — Deprecated banner shown above; not Experimental / Non-standard.
  • Setter is a no-operation and is ignored; assigning does not throw (MDN).
  • Prefer document.fullscreenElement !== null (MDN).
  • Related Fullscreen APIs: fullscreenEnabled, requestFullscreen, exitFullscreen.
  • Related: fragmentDirective, forms, Document constructor.

Legacy / Deprecated Support

Document.fullscreen is deprecated on MDN. Prefer fullscreenElement for new checks. Logos use the shared browser-image-sprite.png sprite from this project.

Deprecated · Prefer fullscreenElement

Document.fullscreen

Obsolete Boolean fullscreen flag — use document.fullscreenElement !== null instead.

Legacy Compatibility only
Google Chrome May still expose · prefer Element API
Legacy / limited
Mozilla Firefox Legacy support · prefer alternatives
Legacy / limited
Apple Safari Do not rely on deprecated Boolean
Legacy / limited
Microsoft Edge Chromium · avoid new use
Legacy / limited
Opera Follow Chromium deprecation path
Legacy / limited
Internet Explorer Historical / prefixed Fullscreen paths
Legacy support
Document.fullscreen Avoid in new code

Bottom line: Recognize document.fullscreen in old scripts. For new work, detect with fullscreenElement and control fullscreen via requestFullscreen / exitFullscreen.

Conclusion

Document.fullscreen is a deprecated yes/no flag for fullscreen mode. Learn it to maintain old code—then migrate checks to document.fullscreenElement !== null and control fullscreen with the modern Fullscreen API.

Continue with fullscreenElement, fragmentDirective, forms, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Check document.fullscreenElement !== null
  • Enter fullscreen only from a user gesture
  • Listen for fullscreenchange to update UI
  • Handle fullscreenerror gracefully
  • Treat document.fullscreen as tech debt

❌ Don’t

  • Use document.fullscreen in new features
  • Assign to document.fullscreen hoping to enter fullscreen
  • Ignore permission / policy blocks
  • Forget Esc / system UI can exit fullscreen anytime
  • Poll the property instead of using events

Key Takeaways

Knowledge Unlocked

Five things to remember about document.fullscreen

Deprecated Boolean flag — prefer fullscreenElement.

5
Core concepts
⚠️02

Status

deprecated

MDN
03

Means

fullscreen on?

Legacy
🚫04

Setter

no-op

Ignored
05

Replace

fullscreenElement

Modern

❓ Frequently Asked Questions

A Boolean that is true if the document is currently displaying an element in fullscreen mode; otherwise false (MDN).
Yes. MDN marks Document.fullscreen deprecated (obsolete). Prefer checking document.fullscreenElement !== null.
Use Document.fullscreenElement. If it is not null, fullscreen mode is active and that Element is the one being presented (MDN).
The property is read-only, but assigning to it does not throw — even in strict mode. The setter is a no-operation and is ignored (MDN).
Call element.requestFullscreen() to enter and document.exitFullscreen() to leave. Check document.fullscreenEnabled first when needed.
No. Learn it only to read legacy code. New checks should use fullscreenElement.
Did you know?

The Fullscreen Standard still mentions document.fullscreen as a historical attribute and tells authors to use fullscreenElement instead. The Boolean remains mainly for compatibility with older pages—not as the API you should design around.

Next: fullscreenElement

Learn the modern Fullscreen API status property.

fullscreenElement →

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.

6 people found this page helpful