Document.pictureInPictureElement is a read-only instance property that returns the Element currently shown in picture-in-picture (PiP) mode, or null. Learn MDN’s exit helper, how it parallels fullscreenElement, video PiP workflows, and five examples with try-it labs.
01
Kind
Read-only property
02
Returns
Element | null
03
Active?
!== null
04
Exit
exitPictureInPicture
05
API
PiP / video
06
Status
Limited avail.
Fundamentals
Introduction
Picture-in-picture mode lets users watch a video in a small floating window while continuing to browse the page. When PiP is active, scripts need to know which element is playing in that window—that is what document.pictureInPictureElement provides.
MDN: the read-only property returns the Element that is currently being presented in picture-in-picture mode in this document, or null if picture-in-picture mode is not currently in use.
💡
Parallel to fullscreen
Think of it like document.fullscreenElement: one property tells you whether a special presentation mode is on and which DOM element is involved.
Four facts about document.pictureInPictureElement.
Type
Element|null
Read-only
Mode
PiP
Floating window
Active?
!== null
Status check
Status
limited
Not Baseline
Compare
📋 pictureInPictureElement vs fullscreenElement
pictureInPictureElement
fullscreenElement
Presentation
Small floating PiP window
Full screen
Typical media
Video (most common)
Video, canvas, div, etc.
Enter API
video.requestPictureInPicture()
element.requestFullscreen()
Exit API
document.exitPictureInPicture()
document.exitFullscreen()
Hands-On
Examples Gallery
Examples follow MDN Document: pictureInPictureElement. Try-it labs read the property safely; enter PiP from a user click where the browser supports it.
📚 Getting Started
Read the property and detect picture-in-picture mode.
Example 1 — Read When PiP Is Off
On a normal page, the property is null until PiP starts.
JavaScript
console.log(document.pictureInPictureElement);
// null when PiP is not active
console.log(document.pictureInPictureElement === null);
null means no element from this document is currently in the PiP window.
Example 2 — MDN exitPictureInPicture() Helper
Only call exit when the property is truthy (MDN example).
JavaScript
function exitPictureInPicture() {
if (document.pictureInPictureElement) {
document.exitPictureInPicture();
}
}
exitPictureInPicture(); // no-op when null
Document.pictureInPictureElement is marked Limited availability on MDN (not Baseline). Feature-detect with pictureInPictureEnabled before production use. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Limited availability · Not Baseline
Document.pictureInPictureElement
Read-only Element in picture-in-picture mode, or null — Picture-in-Picture API status check.
Bottom line: Use pictureInPictureElement !== null to detect PiP. Pair with requestPictureInPicture / exitPictureInPicture and enterpictureinpicture / leavepictureinpicture events.
Wrap Up
Conclusion
Document.pictureInPictureElement tells you which element (if any) is playing in picture-in-picture mode. Check it before calling exitPictureInPicture(), mirror the pattern of fullscreenElement, and keep UI in sync with PiP events.
Listen for enterpictureinpicture and leavepictureinpicture
Guard exitPictureInPicture() with a truthy property check (MDN)
❌ Don’t
Assign to pictureInPictureElement expecting to enter PiP
Assume PiP works in every browser (Limited availability)
Expect parent-document access to iframe PiP elements (MDN: null)
Auto-open PiP without user interaction
Poll the property in a tight loop instead of using events
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about pictureInPictureElement
Element or null — the PiP status property.
5
Core concepts
🎬01
Returns
Element | null
API
✓02
Active
!== null
Check
🚪03
Exit
exitPictureInPicture
MDN
🎥04
Enter
requestPiP
Video
🔄05
Events
enter / leave
Sync UI
❓ Frequently Asked Questions
The Element currently presented in picture-in-picture mode in this document, or null if PiP mode is not in use (MDN).
No. MDN marks it as Limited availability (not Baseline), but not Deprecated, Experimental, or Non-standard. Feature-detect before relying on it in production.
When picture-in-picture mode is not active, when there is no associated PiP element, or when the element is from an iframe (MDN).
No meaningful assignment. The property is read-only; modifying it does not throw even in strict mode — the setter is a no-operation and is ignored (MDN).
MDN example: if document.pictureInPictureElement is truthy, call document.exitPictureInPicture(). Users can also close PiP with browser UI.
fullscreenElement returns the element in fullscreen mode. pictureInPictureElement returns the element in the floating PiP window. They are separate APIs for different presentation modes.
Did you know?
MDN notes that although pictureInPictureElement is read-only, assigning to it does not throw—even in strict mode. The setter is ignored. To enter PiP, call requestPictureInPicture() on a video element instead.