IE11 SVG background images not displaying correctly

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.


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


 .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).

  <img src="" alt=""/>

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

  <img src="" alt=""/>

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

  <img src="" alt=""/>

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.