Skip to content

Instantly share code, notes, and snippets.

@kopitar
Last active November 6, 2018 07:33
Show Gist options
  • Save kopitar/d41d5c02ed81506f4e420e13dcda281c to your computer and use it in GitHub Desktop.
Save kopitar/d41d5c02ed81506f4e420e13dcda281c to your computer and use it in GitHub Desktop.
Internet Explorer - targeting by Media queries and conditional statements
***********************************************
TARGET BY MEDIA QUERIES:
<!-- IE10 & IE 11 -->
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
/* IE10+ CSS styles go here */
}
<!-- IE10 -->
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
.selector {
property:value\9;
}
}
<!-- IE9+ -->
@media screen and (min-width:0) and (min-resolution: .001dpcm) {
.selector {
property:value;
}
}
<!-- IE9 -->
@media screen and (min-width:0) and (min-resolution: +72dpi) {
.selector {
property:value;
}
}
***********************************************
UNDERSCORE HACKS
/* Internet Explorer 11+ */
_:-ms-fullscreen, :root .ie11up { property:value; }
/* Internet Explorer 10+ */
_:-ms-lang(x), .ie10up { property:value; }
/* Internet Explorer 10 (only) */
_:-ms-lang(x), .ie10 { property:value\9; }
***********************************************
CONDITIONAL TARGETING
<!--[if IE ]>
<link href="iecss.css" rel="stylesheet" type="text/css">
<![endif]-->
<!--[if lt IE 7 ]>
<p>Only less than IE 7 will see this</p>
<![endif]-->
Table 1. Conditional Comment Operators
Operator Description
IE represents Internet Explorer; if a number value is also
specified, it represents a version vector
lt less than operator
lte less than or equal to
gt greater than
gte greater than or equal to
! the NOT operator
() subexpression operator
& the AND operator
| the OR operator
true evaluates to true
false evaluates to false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment