IE11 SVG background images not displaying correctly

The Problem

There is an issue with IE11 when rendering some types of SVG files the styles are embedded as a <style></style> element inside the SVG file.

Because IE11 uses a different rendering engine for CSS images and HTML images the images differ from when including the SVG file inside compared to when using the <img> tag.

 E.g.

<img src="/images/badge.svg" width="32" height="32"/>

 vs

 .badge{ background-image: url('/images/badge.svg'); }

The Solution

In total there are four ways of exporting an SVG from Illustrator or other tools:

  1. Presentation Attributes

  2. Style Attributes

  3. Style Attributes (Entity Reference)

  4. Style Elements (this does not work in IE)

In order to export the SVG file correctly follow these steps (Adobe Illustrator CC 2017).

1.Open the SVG file if it’s not already open. Go to File > Export > Export As

2. Select SVG as Format from the dropdown and click on the Export button.

3. On the next screen make sure that the selection for Styling is Inline Style. Click the OK button.

That’s it. Now the SVG element will display correctly.