css only for ie code example

Example 1: css for internet explorer only

@media all and (-ms-high-contrast: none), 
               (-ms-high-contrast: active) {
  /* IE10+ CSS styles goes underneath */
  #ie11 h2 {
    color: #fff;
  }
  #ie11 h2:hover {
    color: gray;
  }
}

Example 2: only ie css

@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
   #myElement {
        /* Enter your style code */
   }
}

Example 3: styles only for IE

@media all and (-ms-high-contrast:none)
     {
     .foo { color: green } /* IE10 */
     *::-ms-backdrop, .foo { color: red } /* IE11 */
     }

Tags:

Css Example