WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
REOPENED
284973
@media (prefers-color-scheme: dark) inside iframe not matching when the iframe itself has style.colorScheme = 'dark'
https://bugs.webkit.org/show_bug.cgi?id=284973
Summary
@media (prefers-color-scheme: dark) inside iframe not matching when the ifram...
Cetin Sert
Reported
2024-12-19 13:37:57 PST
When embedding a webpage inside an <iframe> and setting the iframe’s style to color-scheme: dark, other browsers correctly treat the framed document as if it supports and prefers a dark color scheme. As a result, @media (prefers-color-scheme: dark) rules inside the iframe correctly apply. However, in Safari (WebKit), the @media (prefers-color-scheme: dark) inside the iframe does not match, despite the iframe being explicitly set to color-scheme: dark. Neither adding a <meta name=color-scheme content="dark light"> inside the iframe’s content nor other workarounds produce the expected behavior. Interactive playground with minimal reproduction:
https://wk.rt.ht/bug/iframe/prefers-color-scheme/?io
Works in latest stable Chrome/Edge (131), Firefox (133). Doesn't work in Safari (18.2)! Code <iframe style=color-scheme:dark srcdoc=" <style> body { font-family: system-ui; display: grid; place-items: center; height: 100dvh; margin: 0; } /* ↓ doesn't work in Safari */ @media (prefers-color-scheme: dark) { body { background: #222; color: #fff; } } </style> <h2>I'm an iframe!</h2> "> </iframe> This breaks output color scheme toggling on RTCode.io and potentially other playgrounds!
Attachments
Add attachment
proposed patch, testcase, etc.
Aditya Keerthi
Comment 1
2024-12-23 13:44:40 PST
(this is because WebKit has not implemented the resolution in
https://github.com/w3c/csswg-drafts/issues/7493
yet)
Cetin Sert
Comment 2
2024-12-23 22:52:09 PST
@Apple, see –
https://github.com/w3c/csswg-drafts/issues/7493#issuecomment-1201691078
Looking forward to seeing your swift progress on this!
Radar WebKit Bug Importer
Comment 3
2024-12-26 13:38:14 PST
<
rdar://problem/142072593
>
Cetin Sert
Comment 4
2025-03-03 19:13:52 PST
Hope to see this in the next release!
Jacob Bandes-Storch
Comment 5
2025-08-07 16:04:45 PDT
Just ran into this as well. Would love to see this fixed – any update yet? 🙏
Kiet Ho
Comment 6
2026-03-10 12:41:46 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/60290
Kiet Ho
Comment 7
2026-04-01 13:48:28 PDT
Submitted web-platform-tests pull request:
https://github.com/web-platform-tests/wpt/pull/58920
EWS
Comment 8
2026-04-02 13:47:49 PDT
Committed
310465@main
(34fc452fa59f): <
https://commits.webkit.org/310465@main
> Reviewed commits have been landed. Closing PR #60290 and removing active labels.
Cetin Sert
Comment 9
2026-05-09 11:13:56 PDT
Thank you everyone! Is this in 26.4 or a future version!?
Kiet Ho
Comment 10
2026-05-09 11:32:18 PDT
This is available in STP 242 and newer, see this release note:
https://developer.apple.com/documentation/safari-technology-preview-release-notes/stp-release-242
I don't know which iOS/macOS version would include this, sorry.
Cetin Sert
Comment 11
2026-05-09 16:10:25 PDT
In STP Release 243 (WebKit 22625.1.15.19.1), this has improved a bit but your fix requires a reload of the host document in Safari, while other browser engines just work with host document reloads! --- 1. Open
https://wk.rt.ht/bug/iframe/prefers-color-scheme/
2. Press the "Toggle iframe color-scheme" button (Firefox/Chrome/Edge → ✔️ updates; Safari → ❌ nothing happens) --- 1. Open
https://wk.rt.ht/bug/iframe/prefers-color-scheme/?io
2. Press the "Toggle iframe color-scheme" button (Firefox/Chrome/Edge → ✔️ updates; Safari → ❌ nothing happens) 3. Press F5 to reload the host document too (Safari → ⚠️ updates on host document reload) Safari → does not work) --- Can you re-open this issue and redo your fix?
Cetin Sert
Comment 12
2026-05-09 16:11:46 PDT
Reopened due to the above issue!
Cetin Sert
Comment 13
2026-05-09 16:13:21 PDT
In STP Release 243 (WebKit 22625.1.15.19.1), this has improved a bit but your fix requires a reload of the host document in Safari, while other browser engines just work with host document reloads! --- 1. Open
https://wk.rt.ht/bug/iframe/prefers-color-scheme/
2. Press the "Toggle iframe color-scheme" button (Firefox/Chrome/Edge → ✔️ updates; Safari → ❌ nothing happens) --- 1. Open
https://wk.rt.ht/bug/iframe/prefers-color-scheme/?io
2. Press the "Toggle iframe color-scheme" button (Firefox/Chrome/Edge → ✔️ updates; Safari → ❌ nothing happens) 3. Press F5 to reload the host document too (Safari → ⚠️ updates only on host document reload)
Cetin Sert
Comment 14
2026-05-09 16:33:34 PDT
In STP Release 243 (WebKit 22625.1.15.19.1), this has improved a bit but your fix requires a reload of the host document in Safari, while other browser engines just work withOUT host document reloads! --- 1. Open
https://wk.rt.ht/bug/iframe/prefers-color-scheme/
2. Press the "Toggle iframe color-scheme" button (Firefox/Chrome/Edge → ✔️ updates; Safari → ❌ nothing happens) --- 1. Open
https://wk.rt.ht/bug/iframe/prefers-color-scheme/?io
2. Press the "Toggle iframe color-scheme" button (Firefox/Chrome/Edge → ✔️ updates; Safari → ❌ nothing happens) 3. Press F5 to reload the host document too (Safari → ⚠️ updates only on host document reload)
Cetin Sert
Comment 15
2026-05-09 18:52:14 PDT
Dynamic changes to color-scheme on the embedding iframe element do not cause prefers-color-scheme media queries in the embedded document to be re-evaluated.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug