JavaScript Document fullscreenElement Property

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

What You’ll Learn

Document.fullscreenElement is a read-only instance property that returns the Element currently shown in fullscreen, or null. Learn how it replaces deprecated document.fullscreen, how to detect video fullscreen, toggle with the Fullscreen API, and five examples with try-it labs.

01

Kind

Read-only property

02

Returns

Element | null

03

Active?

!== null

04

vs

document.fullscreen

05

API

Fullscreen API

06

Status

Limited avail.

Introduction

When a page expands a video, canvas, or gallery to fill the screen, scripts need two answers: “Is fullscreen on?” and “Which element is fullscreen?” document.fullscreenElement answers both.

MDN: the property returns the Element currently presented in fullscreen mode in this document, or null if fullscreen mode is not in use. It is the modern replacement for the deprecated document.fullscreen Boolean.

💡
Limited availability

MDN marks this property Limited availability (not Baseline). It is not Deprecated, Experimental, or Non-standard—still feature-detect ("fullscreenElement" in document) before relying on it.

Related Document tutorials: fullscreen, fragmentDirective, Document constructor.

Understanding Document.fullscreenElement

A read-only instance property on Document (also available on shadow roots via the same Fullscreen API model).

  • Value — fullscreen Element, or null when not in fullscreen (MDN).
  • Topmost wins — if multiple elements are fullscreen, the most recently requested is returned (MDN).
  • Active checkdocument.fullscreenElement !== null.
  • Lenient setter — assigning does not throw; the write is ignored (MDN).
  • Control — enter with element.requestFullscreen(); exit with document.exitFullscreen().

📝 Syntax

JavaScript
document.fullscreenElement

Value

The Element currently in fullscreen mode, or null if fullscreen is not in use (MDN).

MDN video helper

JavaScript
function isVideoInFullscreen() {
  if (document.fullscreenElement?.nodeName === "VIDEO") {
    return true;
  }
  return false;
}

⚡ Quick Reference

GoalCode / note
Is fullscreen on?document.fullscreenElement !== null
Which element?document.fullscreenElement
Is it a video?document.fullscreenElement?.nodeName === "VIDEO"
Enterawait el.requestFullscreen()
Exitawait document.exitFullscreen()
MDN statusLimited availability (not Baseline)

🔍 At a Glance

Four facts about document.fullscreenElement.

Type
Element | null

Read-only

Active
!== null

Yes / no

Multiple
topmost

Most recent

Status
limited

Not Baseline

📋 fullscreenElement vs fullscreen

fullscreenElementdocument.fullscreen
TypeElement | nullboolean
Recommended?YesNo — deprecated
Shows which element?YesNo
Active check!== null=== true

Examples Gallery

Examples follow MDN Document: fullscreenElement. Entering fullscreen usually requires a user gesture (button click).

📚 Getting Started

Read the property and detect fullscreen with the modern check.

Example 1 — Read fullscreenElement (Windowed)

On a normal page, the value is null.

JavaScript
console.log(document.fullscreenElement); // null when not fullscreen
console.log("active?", document.fullscreenElement !== null);
Try It Yourself

How It Works

Always null-check before reading id, tagName, or other element fields.

Example 2 — MDN: isVideoInFullscreen()

Return true only when the fullscreen element is a <video>.

JavaScript
function isVideoInFullscreen() {
  if (document.fullscreenElement?.nodeName === "VIDEO") {
    return true;
  }
  return false;
}

console.log(isVideoInFullscreen());
Try It Yourself

How It Works

Optional chaining (?.) keeps the check safe when fullscreenElement is null.

📈 Toggle, Inspect & Events

Enter/exit fullscreen and react when the element changes.

Example 3 — Toggle Using fullscreenElement

If null, request fullscreen; otherwise exit.

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

document.getElementById("toggle").addEventListener("click", async () => {
  try {
    if (!document.fullscreenElement) {
      await stage.requestFullscreen();
    } else {
      await document.exitFullscreen();
    }
  } catch (err) {
    console.error(err);
  }
  console.log("now:", document.fullscreenElement);
});
Try It Yourself

How It Works

Browsers typically require the click handler (user activation) before entering fullscreen.

Example 4 — Log Tag and Id of the Fullscreen Element

Inspect the live element once fullscreen is active.

JavaScript
function describeFullscreen() {
  const el = document.fullscreenElement;
  if (!el) return "not fullscreen";
  return `${el.tagName}#${el.id || "(no id)"}`;
}

document.addEventListener("fullscreenchange", () => {
  console.log(describeFullscreen());
});
Try It Yourself

How It Works

Use this pattern to sync button labels (“Enter” / “Exit”) with the real fullscreen target.

Example 5 — fullscreenchange + Error Handling

Keep UI in sync and catch denied requests.

JavaScript
document.addEventListener("fullscreenchange", () => {
  console.log("active?", document.fullscreenElement !== null);
});

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

How It Works

Esc, OS UI, or exitFullscreen() all fire fullscreenchange—no polling needed.

🚀 Common Use Cases

  • Toggle buttons — enter when null, exit when set.
  • Video players — detect if the fullscreen target is VIDEO (MDN).
  • Games / canvases — confirm which stage element is fullscreen.
  • CSS hooks — pair with the :fullscreen pseudo-class for styling.
  • Replacing legacy code — migrate from document.fullscreen.
  • Accessibility / focus — restore focus when fullscreenElement becomes null.

🧠 How fullscreenElement Updates

1

Script calls requestFullscreen()

Usually from a click handler on a specific element.

Enter
2

Browser promotes the element

That element becomes the document fullscreen element.

State
3

You read fullscreenElement

Non-null Element means fullscreen is active; inspect tag/id as needed.

Query
4

Exit returns null

exitFullscreen(), Esc, or system UI clears the property back to null.

📝 Notes

  • MDN: Limited availability (not Baseline) — no Deprecated / Experimental / Non-standard banner.
  • Preferred replacement for deprecated document.fullscreen.
  • Setter is a no-operation and is ignored; assigning does not throw (MDN).
  • Topmost / most recently requested element wins when multiple exist (MDN).
  • Related: fullscreen, fragmentDirective, Document constructor.

Browser Support

Document.fullscreenElement is marked Limited availability on MDN (not Baseline). Feature-detect before production use. Logos use the shared browser-image-sprite.png sprite from this project.

Limited availability · Not Baseline

Document.fullscreenElement

Read-only Element currently in fullscreen, or null — preferred Fullscreen API status check.

Limited Check compat
Google Chrome Widely supported · Desktop & Mobile
Supported
Mozilla Firefox Supported in modern versions
Supported
Apple Safari Supported with Fullscreen API
Supported
Microsoft Edge Chromium support
Supported
Opera Follow Chromium behavior
Supported
Internet Explorer Not modern Fullscreen API
No / legacy only
Document.fullscreenElement Limited availability

Bottom line: Use fullscreenElement !== null to detect fullscreen and inspect the active Element. Pair with requestFullscreen / exitFullscreen and fullscreenchange events.

Conclusion

Document.fullscreenElement is the standard way to learn which element (if any) is in fullscreen. Prefer it over deprecated document.fullscreen, toggle with requestFullscreen / exitFullscreen, and keep UI in sync with fullscreenchange.

Continue with fullscreenEnabled, fullscreen, fragmentDirective, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Check document.fullscreenElement !== null
  • Feature-detect before production use
  • Enter fullscreen only from a user gesture
  • Listen for fullscreenchange to update UI
  • Use optional chaining when reading nodeName / id

❌ Don’t

  • Rely on deprecated document.fullscreen
  • Assign to fullscreenElement hoping to change mode
  • Assume every browser is Baseline for this API
  • Forget Esc / system UI can clear the element anytime
  • Ignore fullscreenerror when requests fail

Key Takeaways

Knowledge Unlocked

Five things to remember about document.fullscreenElement

Element or null — the modern fullscreen status API.

5
Core concepts
02

Active

!== null

Check
🎬03

Video

nodeName VIDEO

MDN
⚠️04

vs

fullscreen

Prefer this
🔄05

Events

fullscreenchange

Sync UI

❓ Frequently Asked Questions

The Element currently presented in fullscreen mode in this document, or null if fullscreen mode is not in use (MDN).
No. MDN does not mark Document.fullscreenElement as Deprecated, Experimental, or Non-standard. It is Limited availability (not Baseline), so feature-detect in production.
Use document.fullscreenElement !== null. This replaces the deprecated document.fullscreen Boolean.
MDN: the topmost (most recently requested) element is returned.
The property is read-only, but assigning 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. Listen for fullscreenchange to update UI.
Did you know?

The CSS :fullscreen pseudo-class can match elements in fullscreen, while document.fullscreenElement returns only the topmost fullscreen element. They are related but not identical—use the property when your script needs the actual node reference.

Next: fullscreenEnabled

Learn whether fullscreen mode is available for this document.

fullscreenEnabled →

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