Goran Goran - 2 months ago 6
CSS Question

if IE10 or IE11 display different image

I need something like this:

<img src="image.svg" />

<!--[if IE ]><img src="image.png" /><![endif]-->

Since conditional comments are not working any more in IE10 and IE11 I'm having trouble accomplishing this.
Javascript that is available for targeting new internet explorer seems complicated and unreliable. But maybe I'm wrong and there is some simple solution.

Thank you for your help


I think it will be hard to do without any scripts. And the answer given by @eisbehr will work great. But if you don't want to use any other plugins but jQuery, you can check documentMode and add some info to body. Then let css decide what to show or not.

NOTE: it doesn't work in Edge. The code is written specifically for IE10 and IE11, since that's what the OP asked for. But it can be adjusted for different versions. But then I would go with the answer from @eisbehr instead.

$(function() {
    if( document["documentMode"] ) { // If Internet Explorer 10, 11
        var cssClass = "ie" + document["documentMode"];
.ie-dependant {

body.ie11 .ie-dependant.ie11 {
  display: block;

body.ie10 .ie-dependant.ie10 {
  display: block;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="ie-dependant ie10">
  This is ie 10.

<div class="ie-dependant ie11">
  This is ie 11.

Alternatively, you can detect this on server-side, and let the server return different stylesheets.