I have created a very simple SVG that is just a red circle to use as the list-style-image
for my website. I got the idea for this from this SO answer: https://stackoverflow.com/a/19528768/201021
This solution works great except in Internet Explorer. In fact every other browser except IE renders the lists the same way. In IE the SVG image renders a bit larger and sometimes the edges are slightly cut off. See the examples below:
Internet Explorer:
Chrome:
Even with a fixed height & width set in the SVG file it does not render correctly in IE:
The edges are still sometimes cut-off and the markers don't appear to be vertically centered like they should be.
Even when the markers are very small it does not render correctly:
You can see the marker for the third level has edges cut-off.
Also, explicitly setting the height and width instead of using a viewbox means that the markers no longer auto-scale when the font-size is increased which is one reason I chose to go this route.
SVG code for redcircle.svg:
<?xml version="1.0"?>
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<circle cx="50%" cy="50%" r="50%" fill="red" />
</svg>
HTML:
<p>
<ul>
<li>
<span style="line-height: 1.5rem;">Bullet one</span><br>
</li>
<ul>
<li>
<span style="line-height: 1.5rem;">Bullet level two</span>
</li>
<ul>
<li>Bullet level three</li>
</ul>
</ul>
</ul>
</p>
CSS:
ul li {
list-style-image: url("Images/redcircle.svg");
}
I can't really figure out why this is happening except that IE must be doing something different from the other browsers during the rendering of the SVG. Maybe the default size for a list marker in IE is larger or expandable?
I'm a bit at a loss at what to test as well. I've tried changing the viewBox values in the SVG but I've never written an SVG before so I'm not really sure what I'm doing.
Does anyone know why this is happening? Even better does anyone know a workaround to get the SVG to render the same in Internet Explorer?