Apply style ONLY on IE

FastTrack picture FastTrack · Jun 23, 2012 · Viewed 374.2k times · Source

Here is my block of CSS:

.actual-form table {
  padding: 5px 0 15px 15px;
  margin: 0 0 30px 0;
  display: block;
  width: 100%;
  background: #f9f9f9;
  border-top: 1px solid #d0d0d0;
  border-bottom: 1px solid #d0d0d0;
}

I only want IE 7, 8, and 9 to "see" width: 100%

What is the simplest way to accomplish this?

Answer

Himanshu Dwivedi picture Himanshu Dwivedi · Apr 6, 2016
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
   #myElement {
        /* Enter your style code */
   }
}

Explanation: It is a Microsoft-specific media query. Using -ms-high-contrast property specific to Microsoft IE, it will only be parsed in Internet Explorer 10 or greater. I have used both the valid values of the media query, so it will be parsed by IE only, whether the user has high contrast enabled or not.