WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
294315
prefers-color scheme is not applied to svg image when inserted through img or background css
https://bugs.webkit.org/show_bug.cgi?id=294315
Summary
prefers-color scheme is not applied to svg image when inserted through img or...
Karl Dubost
Reported
2025-06-11 01:29:10 PDT
https://wpt.fyi/results/css/mediaqueries/prefers-color-scheme-svg-image.html
https://wpt.live/css/mediaqueries/prefers-color-scheme-svg-image.html
The SVG called directy is changing color depending on the preferred color scheme when called directly. But once it is called through an img element or a CSS background property it fails. The test is basically. <div style="color-scheme: dark"> <img src="resources/prefers-color-scheme.svg"> <div class="background"></div> </div> with the SVG being <svg width="32" height="32" viewBox="0 0 32 32" xmlns="
http://www.w3.org/2000/svg
"> <style> :root { color: blue } @media (prefers-color-scheme: dark) { :root { color: purple } } </style> <rect fill="currentColor" width="32" height="32"/> </svg> The SVG stays blue instead of being purple. This would have impact on anyone using SVG icon with dark theme.
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2025-06-18 01:34:59 PDT
<
rdar://problem/153716346
>
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