<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>199134</bug_id>
          
          <creation_ts>2019-06-23 09:53:15 -0700</creation_ts>
          <short_desc>SVG images don&apos;t support prefers-color-scheme adjustments when embedded in a page</short_desc>
          <delta_ts>2026-04-01 01:26:54 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>SVG</component>
          <version>Safari Technology Preview</version>
          <rep_platform>All</rep_platform>
          <op_sys>macOS 10.14</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=283489</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=309949</see_also>
          <bug_file_loc>https://carpeaqua.com</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Justin Williams">justinw</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>alexphilin</cc>
    
    <cc>aroselli</cc>
    
    <cc>dean_johnson</cc>
    
    <cc>dev</cc>
    
    <cc>eoconnor</cc>
    
    <cc>evan.exe</cc>
    
    <cc>fabioarnold90</cc>
    
    <cc>fstorr</cc>
    
    <cc>gman</cc>
    
    <cc>hello</cc>
    
    <cc>hello+webkit</cc>
    
    <cc>hu.wang</cc>
    
    <cc>karlcow</cc>
    
    <cc>mambolouis</cc>
    
    <cc>mediaformat.ux</cc>
    
    <cc>me</cc>
    
    <cc>nimajneb0905</cc>
    
    <cc>noahbeckman07</cc>
    
    <cc>oliverwilliams345</cc>
    
    <cc>papajuliettcharlie</cc>
    
    <cc>phil</cc>
    
    <cc>roy</cc>
    
    <cc>sabouhallawa</cc>
    
    <cc>samuel</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>timothy</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>webkit</cc>
    
    <cc>zalan</cc>
    
    <cc>zcorpan</cc>
    
    <cc>zimmermann</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1547180</commentid>
    <comment_count>0</comment_count>
      <attachid>372705</attachid>
    <who name="Justin Williams">justinw</who>
    <bug_when>2019-06-23 09:53:15 -0700</bug_when>
    <thetext>Created attachment 372705
This is the SVG I am using

Desktop Safari version: STP Release 85 (Safari 13.0, WebKit 14608.1.28.1)
Mobile Safari: iOS 13 Beta 2

I have an SVG i am trying to update to adopt dark mode using embedded CSS and a @media query. If I open it in the web inspector and toggle dark vs light mode in the Elements tab, it updates the colors appropriately. When embedded in a web page, however, the CSS values are not respected. On the latest version of Firefox it works as expected (or maybe they have a bug and I&apos;m doing it wrong?) 


You can see it live on https://carpeaqua.com.  I&apos;ve also attached the SVG here.

Happy to provide more info as needed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1547268</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-06-24 00:28:59 -0700</bug_when>
    <thetext>&lt;rdar://problem/52044207&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1588110</commentid>
    <comment_count>2</comment_count>
    <who name="Jayden Seric">me</who>
    <bug_when>2019-11-06 21:41:50 -0800</bug_when>
    <thetext>Here is a CodeSandbox demonstrating the issue, along with a table of observed behaviour across browsers:

https://codesandbox.io/s/svg-prefers-color-scheme-media-query-test-7jzlp

Newer Chromium based browsers don’t have this issue (Chrome and Edge v80). Firefox v70.0.1 is ok, although the page must be refreshed after changing the OS color scheme.

It would be extremely useful to be able to use the @media (prefers-color-scheme: dark) media query within SVG files, so that graphics such as logos can adapt themselves for light or dark mode.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1670507</commentid>
    <comment_count>3</comment_count>
    <who name="Louis Hoebregts">mambolouis</who>
    <bug_when>2020-07-10 11:34:56 -0700</bug_when>
    <thetext>This issue is open since a year now and there is no update.
You can see the bug is still happening here:
https://codepen.io/Mamboleoo/pen/XWXYNNL
When opening the SVG file, you get a different color scheme than checking the CodePen page.

As mention before, the media-query is really helpful to handle light/dark icons on our websites.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1710067</commentid>
    <comment_count>4</comment_count>
    <who name="Peter">papajuliettcharlie</who>
    <bug_when>2020-11-25 11:12:15 -0800</bug_when>
    <thetext>Same issue for me. As mention before, the media-query is really helpful to handle light/dark icons on our websites.

Any update on this issue?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1744097</commentid>
    <comment_count>5</comment_count>
    <who name="Alexey Filin">alexphilin</who>
    <bug_when>2021-03-26 01:34:11 -0700</bug_when>
    <thetext>Any update on this issue? Please!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1777723</commentid>
    <comment_count>6</comment_count>
    <who name="Samuel Williams">samuel</who>
    <bug_when>2021-07-17 15:48:35 -0700</bug_when>
    <thetext>I am also having this problem. You can trivially compare the following page in Safari and Chrome/Firefox, etc.

https://github.com/socketry/async

On Safari, the logo currently has black text and a black border. On Chrome, it has white text and a light coloured border.

It actually works if you use the `&lt;object&gt;` tag to embed it. But this is cumbersome to use in practice, and impossible to change for GitHub&apos;s rendering of the markdown -&gt; HTML.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1853201</commentid>
    <comment_count>7</comment_count>
    <who name="Hu">hu.wang</who>
    <bug_when>2022-03-21 08:35:43 -0700</bug_when>
    <thetext>Similar issue for me. In my case, I embed the SVGs as data URLs in the CSS. Works perfectly in Firefox/Chrome just not in Safari.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1882357</commentid>
    <comment_count>8</comment_count>
    <who name="Gregg Tavares">gman</who>
    <bug_when>2022-07-12 00:52:32 -0700</bug_when>
    <thetext>I&apos;d be nice if this was fixed. For example the github repo of the WebGPU spec which Apple is participating in looks like this in Firefox,

https://imgur.com/ZpPFGBN

This in Chrome

https://imgur.com/wEUjG71

And this in Safari

https://imgur.com/9s51nNg</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1882414</commentid>
    <comment_count>9</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2022-07-12 09:55:57 -0700</bug_when>
    <thetext>This is being discussed at https://github.com/w3c/csswg-drafts/issues/7213</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1977037</commentid>
    <comment_count>10</comment_count>
    <who name="Roy Teeuwen">roy</who>
    <bug_when>2023-09-12 02:37:28 -0700</bug_when>
    <thetext>In the meantime a solution has been provided at https://github.com/w3c/csswg-drafts/issues/7213
When will this make it into webkit?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2036733</commentid>
    <comment_count>11</comment_count>
    <who name="Simon Pieters (:zcorpan)">zcorpan</who>
    <bug_when>2024-05-21 07:56:57 -0700</bug_when>
    <thetext>FYI, I ran into this in https://github.com/whatwg/whatwg.org/pull/444 but only using `color-scheme` and `currentColor`.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2099672</commentid>
    <comment_count>12</comment_count>
    <who name="Django Doucet">mediaformat.ux</who>
    <bug_when>2025-03-01 13:48:09 -0800</bug_when>
    <thetext>Still so broken. What is especially cursed is that Safari has no problems detecting `(prefers-color-scheme: light)`, so even having a dark-mode default is not possible
Example test forked from Jayden Seric: https://codesandbox.io/p/devbox/svg-prefers-color-scheme-media-query-test-forked-zmdqft

whatwg proposal was merged, so this should be shipped
https://github.com/whatwg/whatwg.org/pull/444</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2118374</commentid>
    <comment_count>13</comment_count>
    <who name="Nicolò Ribaudo">hello+webkit</who>
    <bug_when>2025-05-20 03:05:23 -0700</bug_when>
    <thetext>(Django Doucet, that PR is not a whatwg proposal to make this work. It&apos;s just a wahtwg website using this feature that doesn&apos;t work in WebKit)

I would also like to see this fixed. It&apos;s not just a nice to have, it is an accessibility issue because not respecting usually `prefers-color-scheme` significantly reduces their contrast when using dark mode.

I noticed this problem in this markdown file (https://github.com/tc39/agendas/blob/main/2025/05.md), where the duration after &quot;Total duration of scheduled discussions&quot; is actually an image. That image is meant to have black text in light mode, and white text in dark mode. I&apos;ve got reports from TC39 delegates using dark mode and webkit that the number was unreadable (black text on dark background), and as a workaround I had to add a white outline to the black text in the default (light mode) image. It looks terrible, but at least it makes it somewhat readable (even though with its own accessibility issues): https://github.com/user-attachments/assets/d8365f12-1d97-4af5-8660-1fc4ef6e21ff.

I&apos;m writing this comment even though other people already said that this bug still happens because:
- to show that multiple people are affected, and it&apos;s not just a niche request
- because I find it funny that  both WHATWG and TC39 are affected :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2132625</commentid>
    <comment_count>14</comment_count>
    <who name="">fstorr</who>
    <bug_when>2025-07-25 18:05:26 -0700</bug_when>
    <thetext>Another vote for getting this bug fixed. Here&apos;s another test case, which shows the bug exists for the img tag but not the object tag: https://cdpn.io/pen/debug/GgpqGVb/26d792ee03de738f73118876f904ba5a</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2132682</commentid>
    <comment_count>15</comment_count>
    <who name="Django Doucet">mediaformat.ux</who>
    <bug_when>2025-07-26 15:32:54 -0700</bug_when>
    <thetext>Accepted by CSSWG Resolution (circa April 2022): 
https://github.com/w3c/csswg-drafts/issues/7213

“Embedded SVGs and iframes can now use prefers-color-scheme media query to add styles that inherit (depend on) the color-scheme of the embedding element.”
https://github.com/mdn/content/pull/20886

If someone with permission could add labels, this would be “needs patch” or equivalent.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2135853</commentid>
    <comment_count>16</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-08-12 00:19:23 -0700</bug_when>
    <thetext>Django, any open issues can be taken.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>372705</attachid>
            <date>2019-06-23 09:53:15 -0700</date>
            <delta_ts>2019-06-23 09:53:15 -0700</delta_ts>
            <desc>This is the SVG I am using</desc>
            <filename>logo.svg</filename>
            <type>image/svg+xml</type>
            <size>901</size>
            <attacher name="Justin Williams">justinw</attacher>
            
              <data encoding="base64">PHN2ZyB3aWR0aD0iMjAwcHgiIGhlaWdodD0iMzBweCIgdmlld0JveD0iMTAgMTEgMjAwIDMwIiB2
ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxp
bms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPCEtLSBHZW5lcmF0b3I6IFNr
ZXRjaCAzLjcuMiAoMjgyNzYpIC0gaHR0cDovL3d3dy5ib2hlbWlhbmNvZGluZy5jb20vc2tldGNo
IC0tPgogICAgPGRlc2M+Q3JlYXRlZCB3aXRoIFNrZXRjaC48L2Rlc2M+CiAgICA8ZGVmcz4KICAg
ICAgPHN0eWxlIHR5cGU9InRleHQvY3NzIj48IVtDREFUQVsKICAgICAgICB0c3BhbiB7CiAgICAg
ICAgICAgIGNvbG9yLXNjaGVtZTogbGlnaHQgZGFyazsKICAgICAgICAgICAgc3VwcG9ydGVkLWNv
bG9yLXNjaGVtZXM6IGxpZ2h0IGRhcms7CiAgICAgICAgfQoKICAJCQkuY2FycGUgeyBmaWxsOiAj
M0UzRTNFOyB9CiAgICAgICAgLmFxdWEgeyBmaWxsOiAjNEE5MEUyOyB9CgogICAgICAgIEBtZWRp
YSAocHJlZmVycy1jb2xvci1zY2hlbWU6IGRhcmspIHsKICAgICAgICAuY2FycGUgeyBmaWxsOiAj
RkZGRkZGOyB9CiAgICAgICAgfQogIAkJXV0+PC9zdHlsZT4KICAgIDwvZGVmcz4KICAgIDx0ZXh0
IGlkPSJjYXJwZWFxdWEiIHN0cm9rZT0ibm9uZSIgZmlsbD0ibm9uZSIgZm9udC1mYW1pbHk9Ii1h
cHBsZS1zeXN0ZW0tYm9keSwgSGVsdmV0aWNhLCBzYW5zLXNlcmlmIiBmb250LXNpemU9IjI0IiBm
b250LXdlaWdodD0ibm9ybWFsIj4KICAgICAgICA8dHNwYW4geD0iMTAiIHk9IjM0IiBjbGFzcz0i
Y2FycGUiPmNhcnBlPC90c3Bhbj4KICAgICAgICA8dHNwYW4geD0iNjguODA0Njg3NSIgeT0iMzQi
IGNsYXNzPSJhcXVhIj5hcXVhPC90c3Bhbj4KICAgIDwvdGV4dD4KPC9zdmc+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>