:picture-in-picture CSS Pseudo Class
Description
The :picture-in-picture pseudo-class targets a media element - typically a video - when it is currently displayed in Picture-in-Picture (PiP) mode. This allows you to apply specific CSS styles only while the element is floating in its own always-on-top window, separate from the main document layout.
This pseudo-class is most commonly used with the video element, since Picture-in-Picture is primarily supported for video playback. When a user activates PiP (usually via the browser’s video controls or context menu), the browser automatically applies this pseudo-class to the relevant element.
What the pseudo-class does
When a video enters Picture-in-Picture mode:
- It is removed from the normal document flow.
- It appears in a floating window managed by the browser or operating system.
- Styles inside your page do not affect the PiP window layout, but you can still adjust properties such as visibility, overlays, or related UI elements in the page itself.
The :picture-in-picture pseudo-class lets you respond visually to that state - for example, hiding placeholder elements, changing layouts, or indicating that PiP is active.
Basic example
video:picture-in-picture {
outline: 3px solid #4a90e2;
}
This applies a visible outline to the video element only while it is in Picture-in-Picture mode.
Example with supporting UI behavior
video:picture-in-picture + .pip-status {
display: block;
}
.pip-status {
display: none;
font-size: 14px;
color: #555;
}
<video controls src="video.mp4"></video>
<div class="pip-status">Picture-in-Picture is active</div>
In this example, a message appears only when the video enters PiP mode.
Related behavior and interactions
- The pseudo-class often works alongside
:fullscreen, but the two are mutually exclusive - a video cannot be fullscreen and in Picture-in-Picture at the same time. - Layout-related properties such as
displayorvisibilityare commonly used to adjust UI elements when PiP is active. - Visual properties like
object-fitmay still affect how the video renders inside its container before entering PiP.
Notes and limitations
- You cannot style the PiP window itself (size, position, or UI controls are browser-managed).
- Support may vary slightly between browsers, especially on mobile.
- The pseudo-class applies only while PiP is active - no JavaScript is required to detect it.
Syntax
:picture-in-picture {
/* ... */
}
Example
Browser Support
The following information will show you the current browser support for the CSS :picture-in-picture pseudo class. Hover over a browser icon to see the version that first introduced support for this CSS psuedo class.
This psuedo class is supported in some modern browsers, but not all.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 31st December 2025
