Copyright © 2026 World Wide Web Consortium. W3C® liability, trademark and permissive document license rules apply.
This specification provides APIs to allow websites to create a floating video window always on top of other windows so that users may continue consuming media while they interact with other content sites, or applications on their device.
This section describes the status of this document at the time of its publication. A list of current W3C publications and the latest revision of this technical report can be found in the W3C standards and drafts index.
Feedback and comments on this specification are welcome. GitHub Issues are preferred for discussion on this specification. Alternatively, you can send comments to the Media Working Group’s mailing-list, public-media-wg@w3.org (archives). This draft highlights some of the pending issues that are still to be discussed in the working group. No decision has been taken on the outcome of these issues including whether they are valid.
This document was published by the Media Working Group as an Editor’s Draft. This document is intended to become a W3C Recommendation.
Publication as an Editor’s Draft does not imply endorsement by W3C and its Members.
This document was produced by a group operating under the W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent that the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
This document is governed by the 18 August 2025 W3C Process Document.
This section is non-normative.
Many users want to continue consuming media while they interact with other content, sites, or applications on their device. A common UI affordance for this type of activity is Picture-in-Picture (PiP), where the video is contained in a separate miniature window that is always on top of other windows. This window stays visible even when the user agent is not visible. Picture-in-Picture is a common platform-level feature among desktop and mobile OSs.
This specification extends HTMLVideoElement allowing websites
to initiate and control this behavior by exposing the following sets of properties:
Notify the website when it enters and leaves Picture-in-Picture mode.
Allow the website to trigger Picture-in-Picture mode via a user gesture on a video element.
Allow the website to know the size of the Picture-in-Picture window and notify the website when it changes.
Allow the website to exit Picture-in-Picture mode.
Allow the website to check if Picture-in-Picture mode can be triggered.
< video id = "video" src = "https://example.com/file.mp4" ></ video > < button id = "togglePipButton" ></ button > < script > const video= document. getElementById( "video" ); const togglePipButton= document. getElementById( "togglePipButton" ); // Hide button if Picture-in-Picture is not supported or disabled. togglePipButton. hidden= ! document. pictureInPictureEnabled|| video. disablePictureInPicture; togglePipButton. addEventListener( "click" , async () => { // If there is no element in Picture-in-Picture yet, let's request // Picture-in-Picture for the video, otherwise leave it. try { if ( document. pictureInPictureElement) { await document. exitPictureInPicture(); } else { await video. requestPictureInPicture(); } } catch ( err) { // Video failed to enter/leave Picture-in-Picture mode. } }); </ script >
< video id = "video" src = "https://example.com/file.mp4" ></ video > < script > const video= document. getElementById( "video" ); video. addEventListener( "enterpictureinpicture" , ( event) => { // Video entered Picture-in-Picture mode. const pipWindow= event. pictureInPictureWindow; console. log( `Picture-in-Picture window width: ${ pipWindow. width} ` ); console. log( `Picture-in-Picture window height: ${ pipWindow. height} ` ); }); video. addEventListener( "leavepictureinpicture" , () => { // Video left Picture-in-Picture mode. }); </ script >
< video id = "video" src = "https://example.com/file.mp4" ></ video > < button id = "pipButton" ></ button > < script > const video= document. getElementById( "video" ); const pipButton= document. getElementById( "pipButton" ); pipButton. addEventListener( "click" , async () => { try { await video. requestPictureInPicture(); } catch ( error) { // Video failed to enter Picture-in-Picture mode. } }); video. addEventListener( "enterpictureinpicture" , ( event) => { // Video entered Picture-in-Picture mode. const pipWindow= event. pictureInPictureWindow; updateVideoSize( pipWindow. width, pipWindow. height); pipWindow. addEventListener( "resize" , onPipWindowResize); }); video. addEventListener( "leavepictureinpicture" , ( event) => { // Video left Picture-in-Picture mode. const pipWindow= event. pictureInPictureWindow; pipWindow. removeEventListener( "resize" , onPipWindowResize); }); function onPipWindowResize( event) { // Picture-in-Picture window has been resized. const { width, height} = event. target; updateVideoSize( width, height); } function updateVideoSize( width, height) { // TODO: Update video size based on pip window width and height. } </ script >
A Picture-in-Picture window is a window displaying the video element.
A DocumentOrShadowRoot has:
A Picture-in-Picture element, which is an Element or null, initially null.
A traversable navigable has:
A picture-in-picture parallel queue, which is a parallel queue created by starting a new parallel queue.
A user agent has:
An initiators of active Picture-in-Picture sessions list of zero or more origins, which is initially empty.
Note: In case a user agent supports multiple Picture-in-Picture windows, the list allows duplicates.
An origin is said to have an active Picture-in-Picture session if any of the origins in initiators of active Picture-in-Picture sessions are same origin-domain with origin.
It is RECOMMENDED that video frames are not rendered in the page and in the Picture-in-Picture window at the same time but if they are, they MUST be kept in sync.
When a video is played in Picture-in-Picture mode, the states SHOULD transition as if it was played inline. That means that the events SHOULD fire at the same time, calling methods SHOULD have the same behaviour, etc. However, the user agent MAY transition out of Picture-in-Picture when the video element enters a state that is considered not compatible with Picture-in-Picture.
Styles applied to video (such as opacity, visibility, transform, etc.) MUST NOT apply in the Picture-in-Picture window. Its aspect ratio is based on the video size.
It is also RECOMMENDED that the Picture-in-Picture window has a maximum and minimum size. For example, it could be restricted to be between a quarter and a half of one dimension of the screen.
When a DocumentOrShadowRoot’s Picture-in-Picture element is set,
the Picture-in-Picture window MUST be visible, even when the
DocumentOrShadowRoot’s relevant global object’s associated Document’s
visibility state is "hidden".
The user agent SHOULD provide a way for users to manually close the
Picture-in-Picture window.
When the exit Picture-in-Picture algorithm is invoked, the user agent MUST run the following steps:
If pictureInPictureElement is null, throw a InvalidStateError and
abort these steps.
Run the close window algorithm with the Picture-in-Picture
window associated with pictureInPictureElement.
Queue a task to fire an event named
leavepictureinpicture using PictureInPictureEvent at the
video with its bubbles attribute initialized to true and its
pictureInPictureWindow attribute initialized to
Picture-in-Picture window associated with pictureInPictureElement.
Unset pictureInPictureElement.
Remove one item matching relevant settings object’s origin from initiators of active Picture-in-Picture sessions.
It is NOT RECOMMENDED that the video playback state changes when the exit Picture-in-Picture algorithm is invoked. The website SHOULD be in control of the experience if it is website initiated. However, the user agent MAY expose Picture-in-Picture window controls that change video playback state (e.g., pause).
As one of the unloading document cleanup steps, run the exit Picture-in-Picture algorithm.
Some pages may want to disable Picture-in-Picture mode for a video element; for
example, they may want to prevent the user agent from suggesting a
Picture-in-Picture context menu in some cases.
To support these use cases, a new disablePictureInPicture
attribute is added to the list of content attributes for video elements.
The disablePictureInPicture IDL attribute MUST reflect the content
attribute of the same name.
If the disablePictureInPicture attribute is present on the video element,
the user agent MAY prevent the video element from playing in Picture-in-Picture
mode or present any UI to do so.
When the disablePictureInPicture attribute is added to a video element,
the user agent MAY run these steps:
Reject any pending promises returned by the requestPictureInPicture()
method with InvalidStateError.
If video is pictureInPictureElement, run the exit
Picture-in-Picture algorithm.
It is RECOMMENDED to run the exit Picture-in-Picture algorithm when the
pictureInPictureElement fullscreen flag is set.
The Picture-in-Picture window visibility MUST NOT be taken into account by the user agent to determine if the system visibility state of a traversable navigable has changed.
Operating systems with a Picture-in-Picture API usually restrict
Picture-in-Picture mode to only one window. Whether only one window is allowed
in Picture-in-Picture mode will be left to the implementation and the platform.
However, because of the one Picture-in-Picture window limitation, the
specification assumes that a given Document can only have one
Picture-in-Picture window.
What happens when there is a Picture-in-Picture request while a window is already in Picture-in-Picture will be left as an implementation detail: the current Picture-in-Picture window could be closed, the Picture-in-Picture request could be rejected or even two Picture-in-Picture windows could be created. Regardless, the User Agent will have to fire the appropriate events in order to notify the website of the Picture-in-Picture status changes.
HTMLVideoElementpartial interface HTMLVideoElement { [NewObject ]Promise <PictureInPictureWindow >();requestPictureInPicture attribute EventHandler ;onenterpictureinpicture attribute EventHandler ; [onleavepictureinpicture CEReactions ]attribute boolean ; };disablePictureInPicture
The requestPictureInPicture() method steps request Picture-in-Picture:
If Picture-in-Picture support is false, return a promise rejected with NotSupportedError DOMException.
Let doc be this’s node document.
If doc is not allowed to use the policy-controlled feature
named "picture-in-picture", return a promise rejected with NotAllowedError DOMException.
If this’s readyState attribute is HAVE_NOTHING, return a promise rejected with InvalidStateError DOMException.
If this has no video track, return a promise rejected with InvalidStateError DOMException.
If this’s disablePictureInPicture is true, user agent may return a promise rejected with InvalidStateError DOMException.
If doc’s Picture-in-Picture element is null:
If this’s relevant global object does not have a transient activation, then return a promise rejected with NotAllowedError DOMException.
Consume user activation given this’s relevant global object.
If this is doc’s Picture-in-Picture element:
Return a promise resolved with the Picture-in-Picture window associated with doc’s Picture-in-Picture element.
Let global be this’s relevant global object.
Let p be a new promise created in this’s relevant realm.
Return p, and enqueue the following steps to doc’s picture-in-picture parallel queue:
If this is doc’s Picture-in-Picture element:
Queue a global task on the media element event task source given global to resolve p with the Picture-in-Picture window associated with this.
Abort these steps.
Attempt to associate a Picture-in-Picture window with this.
If the previous step failed:
Queue a global task on the media element event task source given global to
reject p with InvalidStateError DOMException.
Abort these steps.
Let pipWindow be a new instance of PictureInPictureWindow that represents this’s associated Picture-in-Picture window.
Queue a global task on the media element event task source given global, to perform the following steps:
If pictureInPictureElement is not null, run the exit Picture-in-Picture algorithm.
Set doc’s Picture-in-Picture element to this.
Append relevant settings object’s origin to initiators of active Picture-in-Picture sessions.
If this is fullscreenElement, exit fullscreen.
Fire an event named enterpictureinpicture using PictureInPictureEvent at
this with its bubbles attribute initialized to true and its
pictureInPictureWindow attribute initialized to
Picture-in-Picture window.
Resolve p with pipWindow.
Documentpartial interface Document {readonly attribute boolean ; [pictureInPictureEnabled NewObject ]Promise <undefined >(); };exitPictureInPicture
The pictureInPictureEnabled attribute’s getter must return true if
Picture-in-Picture support is true and this is
allowed to use the feature indicated by attribute name
picture-in-picture, and false otherwise.
Picture-in-Picture support is false if there’s a user preference
that disables it or a platform limitation. It is true otherwise.
The exitPictureInPicture() method, when invoked, MUST
return a new promise promise and run the following steps in
parallel:
Run the exit Picture-in-Picture algorithm.
If the previous step threw an exception, reject promise with that exception and abort these steps.
Resolve promise.
DocumentOrShadowRootpartial interface mixin DocumentOrShadowRoot {readonly attribute Element ?; };pictureInPictureElement
The pictureInPictureElement attribute’s getter must run these steps:
If this is a shadow root and its host
is not connected, return null and abort these steps.
Let candidate be the result of retargeting Picture-in-Picture element against this.
If candidate and this are in the same tree, return candidate and abort these steps.
Return null.
PictureInPictureWindow[Exposed =Window ]interface :PictureInPictureWindow EventTarget {readonly attribute long ;width readonly attribute long ;height attribute EventHandler ; };onresize
A PictureInPictureWindow instance represents a Picture-in-Picture
window associated with an HTMLVideoElement. When instantiated, an
instance of PictureInPictureWindow has its state set to opened.
When the close window algorithm with an instance of
PictureInPictureWindow is invoked, its state is set to closed.
The width attribute MUST return the width in CSS pixels of the
Picture-in-Picture window associated with pictureInPictureElement if
the state is opened. Otherwise, it MUST return 0.
The height attribute MUST return the height in CSS pixels of the
Picture-in-Picture window associated with pictureInPictureElement if
the state is opened. Otherwise, it MUST return 0.
When the size of a Picture-in-Picture window pipWindow changes, the user agent MUST
queue a task to fire an event named resize at pipWindow.
[Exposed =Window ]interface :PictureInPictureEvent Event {(constructor DOMString ,type PictureInPictureEventInit ); [eventInitDict SameObject ]readonly attribute PictureInPictureWindow ; };pictureInPictureWindow dictionary :PictureInPictureEventInit EventInit {required PictureInPictureWindow ; };pictureInPictureWindow
enterpictureinpicture
Fired on a HTMLVideoElement when it enters Picture-in-Picture.
leavepictureinpicture
Fired on a HTMLVideoElement when it leaves Picture-in-Picture mode.
resize
Fired on a PictureInPictureWindow when it changes size.
The task source for all the tasks queued in this specification is the media element event task source of the video element in question.
The :picture-in-picture pseudo-class MUST match the Picture-in-Picture
element. It is different from the pictureInPictureElement as it does NOT
apply to the shadow host chain.
This section is non-normative.
To limit potential abuse through spoofing, the API applies only to
HTMLVideoElement. User interaction with the Picture-in-Picture window
is intentionally limited so that the only effect is on the Picture-in-Picture
window itself or the media being played.
The API is not limited to [SECURE-CONTEXTS] because it exposes a feature to web applications that user agents usually offer natively on all media regardless of the browsing context.
This specification defines a policy-controlled feature named
"picture-in-picture" that controls whether request Picture-in-Picture
returns a SecurityError and whether
pictureInPictureEnabled is true or false.
The default allowlist for this feature is *.
Thanks to Jennifer Apacible, Zouhir Chahoud, Marcos Cáceres, Philip Jägenstedt, Jeremy Jones, Chris Needham, Jer Noble, Justin Uberti, Yoav Weiss, and Eckhart Wörner for their contributions to this document.
Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.
All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]
Examples in this specification are introduced with the words “for example”
or are set apart from the normative text
with class="example",
like this:
Informative notes begin with the word “Note”
and are set apart from the normative text
with class="note",
like this:
Note, this is an informative note.
Requirements phrased in the imperative as part of algorithms (such as "strip any leading space characters" or "return false and abort these steps") are to be interpreted with the meaning of the key word ("must", "should", "may", etc) used in introducing the algorithm.
Conformance requirements phrased as algorithms or specific steps can be implemented in any manner, so long as the end result is equivalent. In particular, the algorithms defined in this specification are intended to be easy to understand and are not intended to be performant. Implementers are encouraged to optimize.
partial interface HTMLVideoElement { [NewObject ]Promise <PictureInPictureWindow >();requestPictureInPicture attribute EventHandler ;onenterpictureinpicture attribute EventHandler ; [onleavepictureinpicture CEReactions ]attribute boolean ; };disablePictureInPicture partial interface Document {readonly attribute boolean ; [pictureInPictureEnabled NewObject ]Promise <undefined >(); };exitPictureInPicture partial interface mixin DocumentOrShadowRoot {readonly attribute Element ?; }; [pictureInPictureElement Exposed =Window ]interface :PictureInPictureWindow EventTarget {readonly attribute long ;width readonly attribute long ;height attribute EventHandler ; }; [onresize Exposed =Window ]interface :PictureInPictureEvent Event {(constructor DOMString ,type PictureInPictureEventInit ); [eventInitDict SameObject ]readonly attribute PictureInPictureWindow ; };pictureInPictureWindow dictionary :PictureInPictureEventInit EventInit {required PictureInPictureWindow ; };pictureInPictureWindow