Skip to content

Instantly share code, notes, and snippets.

@necolas
Created May 20, 2011 15:10
Show Gist options
  • Star 46 You must be signed in to star a gist
  • Fork 15 You must be signed in to fork a gist
  • Save necolas/983116 to your computer and use it in GitHub Desktop.
Save necolas/983116 to your computer and use it in GitHub Desktop.
IE CSS hacks
/*
* Property prefix hacks
*/
/* IE6 only - any combination of these characters */
_ - £ ¬ ¦
/* IE6/7 only - any combination of these characters */
! $ & * ( ) = % + @ , . / ` [ ] # ~ ? : < > |
/*
* @media hacks
*/
/* IE6/7 only (via Keith Clarke) */
@media screen\9 { }
/* IE6/7/8 (via Keith Clarke) */
@media \0screen\,screen\9 {}
/* IE8 (via Keith Clarke) */
@media \0screen { }
/* IE8/9 (maybe IE10 final) */
@media screen\0 { }
@mathiasbynens
Copy link

Some more here: http://mathiasbynens.be/demo/css-hacks (view in the browser of your choice)

@yairEO
Copy link

yairEO commented Jun 30, 2013

/* IE8/9 (maybe IE10 final) */

@media screen\0 { }

yes, it's definitely working on IE10.

@jslegers
Copy link

"@media \0screen,screen\9 {}" and "@media \0screen { }" don't work in IE8 when I minify my css.

@jslegers
Copy link

@mathiasbynens
Copy link

See 4ae9b8/browserhacks#101 for follow-up discussion.

@shantikumarsingh
Copy link

what about hack for different IE screen resolutions?

Anyone have answers for below code:
@media (min-width:1366px) and (max-width:1500px){
.header{height:200px;}
}
@media (min-width:1280px) and (max-width:1365px){
.header{height:150px}
}

Have tried using below code but does not work.

@media screen\9 and (min-width:1366px) {
.header{height:200px}
}
@media screen\9 and (min-width:1280px) {
.header{height:150px}
}

@ttnesyoo
Copy link

ttnesyoo commented Oct 1, 2018

<style> .ImgST { float:right; BORDER-TOP: 1px solid; BORDER-RIGHT: 1px solid; BORDER-BOTTOM: 1px solid; BORDER-LEFT: 1px solid; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; PADDING-LEFT: 2px; PADDING-RIGHT: 2px; } </style>

@Mouvedia
Copy link

Mouvedia commented Feb 22, 2021

It seems like you might be able to filter out internet explorer using the attribute selector.
e.g. html[lang="En"] instead of html[lang="en"]

https://stackoverflow.com/a/3870890/248058

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment