<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/creating-web-widgets-using-the-document-picture-in-picture-api-cknshso6s" -->

---
title: Creating Web Widgets Using the Document...
description: Firefox 151 shipped the Document Picture-in-Picture API, which unlike the regular Picture-in-Picture API for videos, lets developers put arbitrary HTML, CSS,...
canonical: https://daily.dev/posts/creating-web-widgets-using-the-document-picture-in-picture-api-cknshso6s
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Creating Web Widgets Using the Document Picture-in-Picture API | daily.dev
og:description: Firefox 151 shipped the Document Picture-in-Picture API, which unlike the regular Picture-in-Picture API for videos, lets developers put arbitrary HTML, CSS,...
og:url: https://daily.dev/posts/creating-web-widgets-using-the-document-picture-in-picture-api-cknshso6s
og:image: https://api.daily.dev/og/posts/cknsHsO6s.png
og:image:alt: Creating Web Widgets Using the Document Picture-in-Picture API
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating Web Widgets Using the Document Picture-in-Picture API

**[CSS-Tricks](https://daily.dev/sources/css_tricks)** · 7 min read · 2 upvotes · 0 comments

## Summary

Firefox 151 shipped the Document Picture-in-Picture API, which unlike the regular Picture-in-Picture API for videos, lets developers put arbitrary HTML, CSS, and JavaScript into an always-on-top window as a floating widget. A walkthrough covers checking browser support via JavaScript (since feature queries can't detect it yet), creating a DPIP window with requestWindow(), cloning an existing HTML component and its stylesheets into the new window using cloneNode() and document fragments, and writing targeted CSS with the display-mode media query. Safari does not yet support the API, and the demo requires Chrome or Firefox in debug mode outside an iframe.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://css-tricks.com/creating-web-widgets-using-the-document-picture-in-picture-api>

## Questions this post answers

### How do I check if a browser supports the Document Picture-in-Picture API?

Check for the documentPictureInPicture property on the window object using JavaScript, since there is no CSS feature-query way to detect support. The at-rule() function needed for @supports detection is only implemented in Chrome, and plans to support preludes like display-mode: picture-in-picture appear to have been dropped, so a JavaScript check like `if (!("documentPictureInPicture" in window))` is required instead.

_daily.dev surfaces browser API support nuances like this for developers building resilient feature detection._

### Which browsers support the Document Picture-in-Picture API?

Chrome supports it, and Firefox added support starting with Firefox 151. Safari does not support the Document Picture-in-Picture API yet, though Safari Technology Preview 251 release notes mention upcoming support for at-rule detection in @supports, with no clear rollout timeline given.

_Track cross-browser API rollouts like this on daily.dev before committing to a widget design._

### How do I clone an HTML element and its styles into a Document Picture-in-Picture window in JavaScript?

Use requestWindow() to create the DPIP window, then clone the target element with cloneNode(true) and append it to DPIP.document.body. For styles, select all style and link[rel=stylesheet] elements, clone them into a document fragment via createDocumentFragment() and forEach(), then append the fragment once to DPIP.document.head to trigger a single reflow instead of many.

_daily.dev helps developers piece together practical DOM cloning patterns like this one for widget UIs._

## Similar posts on daily.dev

- [Enter video Picture-in-Picture automatically on more sites](https://daily.dev/posts/enter-video-picture-in-picture-automatically-on-more-sites-zc5eahtrd) · Chrome Developers · 0 upvotes · 0 comments
- [O and the 'era of the agentic web'. — Frontend Focus](https://daily.dev/posts/o-and-the-era-of-the-agentic-web-frontend-focus-pjkev5kwo) · Frontend Focus · 0 upvotes · 0 comments
- [Arc-like automatic picture-in-picture in Chromium](https://daily.dev/posts/arc-like-automatic-picture-in-picture-in-chromium-umvv4lnbu) · Dave Rupert · 0 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#javascript](https://daily.dev/tags/javascript), [#css](https://daily.dev/tags/css), [#firefox](https://daily.dev/tags/firefox)

[View this post on daily.dev](https://daily.dev/posts/creating-web-widgets-using-the-document-picture-in-picture-api-cknshso6s)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Creating Web Widgets Using the Document Picture-in-Picture API","url":"https://daily.dev/posts/creating-web-widgets-using-the-document-picture-in-picture-api-cknshso6s","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/creating-web-widgets-using-the-document-picture-in-picture-api-cknshso6s"},"datePublished":"2026-08-27T14:43:12.983Z","dateModified":"2026-09-13T21:11:48.625Z","description":"Firefox 151 shipped the Document Picture-in-Picture API, which unlike the regular Picture-in-Picture API for videos, lets developers put arbitrary HTML, CSS,...","image":"https://i0.wp.com/css-tricks.com/wp-content/uploads/2019/05/framed-image.png","thumbnailUrl":"https://i0.wp.com/css-tricks.com/wp-content/uploads/2019/05/framed-image.png","isAccessibleForFree":true,"articleSection":"CSS-Tricks","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"CSS-Tricks","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/css_tricks","url":"https://daily.dev/sources/css_tricks"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/creating-web-widgets-using-the-document-picture-in-picture-api-cknshso6s","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"webdev,javascript,css,firefox","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"CSS-Tricks","item":"https://daily.dev/sources/css_tricks"},{"@type":"ListItem","position":3,"name":"Creating Web Widgets Using the Document Picture-in-Picture API"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/creating-web-widgets-using-the-document-picture-in-picture-api-cknshso6s#faq","mainEntity":[{"@type":"Question","name":"How do I check if a browser supports the Document Picture-in-Picture API?","acceptedAnswer":{"@type":"Answer","text":"Check for the documentPictureInPicture property on the window object using JavaScript, since there is no CSS feature-query way to detect support. The at-rule() function needed for @supports detection is only implemented in Chrome, and plans to support preludes like display-mode: picture-in-picture appear to have been dropped, so a JavaScript check like `if (!(\"documentPictureInPicture\" in window))` is required instead. daily.dev surfaces browser API support nuances like this for developers building resilient feature detection."}},{"@type":"Question","name":"Which browsers support the Document Picture-in-Picture API?","acceptedAnswer":{"@type":"Answer","text":"Chrome supports it, and Firefox added support starting with Firefox 151. Safari does not support the Document Picture-in-Picture API yet, though Safari Technology Preview 251 release notes mention upcoming support for at-rule detection in @supports, with no clear rollout timeline given. Track cross-browser API rollouts like this on daily.dev before committing to a widget design."}},{"@type":"Question","name":"How do I clone an HTML element and its styles into a Document Picture-in-Picture window in JavaScript?","acceptedAnswer":{"@type":"Answer","text":"Use requestWindow() to create the DPIP window, then clone the target element with cloneNode(true) and append it to DPIP.document.body. For styles, select all style and link[rel=stylesheet] elements, clone them into a document fragment via createDocumentFragment() and forEach(), then append the fragment once to DPIP.document.head to trigger a single reflow instead of many. daily.dev helps developers piece together practical DOM cloning patterns like this one for widget UIs."}}]}
```

