[csswg-drafts] [css-color-adjust-1] Just what *are* browsers doing for iframes and inherited color schemes? (#13843)

tabatkins has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-color-adjust-1] Just what *are* browsers doing for iframes and inherited color schemes? ==
In #7493 we resolved to allow iframes to inherit their parent document's color scheme. I was looking over this resolution and part of the spec while editting #13377, and I'm a little confused by the actual behavior and what *precisely* we want.

Here's some example code:

```html
<!DOCTYPE html>
<meta name=color-scheme content=light>
<iframe srcdoc="<!doctype html><meta name=color-scheme content='light dark'><p>foo"></iframe>
```

Here, the `iframe` is light-mode, because the parent is. If you change the parent's markup to `content=dark`, the iframe is dark-mode, again matching the parent. All good!

Now, add `color-scheme:dark;` to the iframe. If the parent is light-mode, suddenly the iframe is white-on-white, unreadable. Similarly, if the parent is `content=dark` while the iframe is set to `color-scheme:light`, it's black-on-black, similarly unreadable.

It looks like the canvas and canvastext colors are drawing from different sources: `canvastext` for the inner document is using the iframe's used color scheme (affected by CSS), while the canvas background is using the outer page's *initial* color scheme (affected by the meta, but not by CSS).

This happens in both Chrome and Firefox, so I presume there's a common reason for this. (I can't test Safari right now.) Can someone explain what's actually going on?

/cc @bfgeek @emilio 

------------

My plan, fwiw, was to define a 'document color scheme' concept that was based on the user pref + meta, and have the `prefers-color-scheme` use that (per the #13377 resolution), and I was trying to decide whether it makes more sense to have child frames inherit the document color scheme or used color scheme. I was surprised to discovere it looks like the answer is both!

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/13843 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 28 April 2026 00:44:08 UTC