Skip to content

Instantly share code, notes, and snippets.

@rolfen
Last active December 8, 2016 14:25
Show Gist options
  • Save rolfen/8bb2f2269b40f877eb9200a02c0dc812 to your computer and use it in GitHub Desktop.
Save rolfen/8bb2f2269b40f877eb9200a02c0dc812 to your computer and use it in GitHub Desktop.
IE CSS hacks
/* Source:
http://stackoverflow.com/a/30743013/370786
*/
/***** Attribute Hacks ******/
/* IE6 */
#once { _color: blue }
/* IE6, IE7 */
#doce { *color: blue; /* or #color: blue */ }
/* Everything but IE6 */
#diecisiete { color/**/: blue }
/* IE6, IE7, IE8, but also IE9 in some cases :( */
#diecinueve { color: blue\9; }
/* IE7, IE8 */
#veinte { color/*\**/: blue\9; }
/* IE6, IE7 -- acts as an !important */
#veintesiete { color: blue !ie; } /* string after ! can be anything */
/* IE8, IE9 */
#anotherone {color: blue\0/;} /* must go at the END of all rules */
/* IE9, IE10 - seems to apply to IE11 as well (and 10, I assume?) */
@media screen and (min-width:0\0) {
#veintidos { color: red}
}
/***** Selector Hacks ******/
/* IE6 and below */
* html #uno { color: red }
/* IE7 */
*:first-child+html #dos { color: red }
/* IE8 (Everything but IE 6,7) */
html>/**/body #cuatro { color: red }
/* Everything but IE6-8 */
:root *> #quince { color: red }
/* IE7 */
*+html #dieciocho { color: red }
/* IE 10+ */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
#veintiun { color: red; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment