7

SVG can be readily viewed in Edge browser. However white SVG on white browser background aren't good to see. Do I need to install an external program for this or am I missing a setting?

2

2 Answers 2

6

There is no direct way to view white SVGs but you can do some hack to view them on a chrome browser. Drag and drop the svg to chrome browser and open the dev tools(f12 or ctrl + shift + i) and change the background color of the topmost DOM element to black and voila you can view the white SVG.

Find the topmost dom and change the background color

white svg on black background

1

I've created a bookmarklet to set the background to a checkerboard pattern. Create a bookmark and set this as the URL

javascript:(function(){document.body.style.background = null;document.body.children[0].style.background=null; document.children[0].style.backgroundImage = `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" fill-opacity="0.3" width="50" height="50" ><g fill="grey"><rect x="50" width="50" height="50" /><rect y="50" width="50" height="50" /></g><rect width="50" height="50" /><rect y="50" x="50" width="50" height="50" /></svg>')`;})();

Then if you load a SVG that is white hit this bookmark and it will set the background to a checkerboard.

I keep improving that bookmarklet so the repo is here: https://github.com/Myster/TransparentBackgroundRevealer It also includes a hotlink to the latest version. So you may wish to fork so you can review any changes.

1
  • Pasting it into the Chrome/Edge Console I get Uncaught TypeError: Cannot read properties of null (reading 'style'), but the GitHub version works OK.
    – mwfearnley
    Feb 1 at 10:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .