Skip to content

Instantly share code, notes, and snippets.

@lsitters
Created December 15, 2009 20:22
Show Gist options
  • Save lsitters/257264 to your computer and use it in GitHub Desktop.
Save lsitters/257264 to your computer and use it in GitHub Desktop.
CSS Hacks
body:empty {
background: blue;
}
body {
background: red;
}
@-moz-document url-prefix() {
body {
background: blue;
}
}
/*
The following hack will target both Safari 3 and Google Chrome.
*/
body {
background: red;
}
@media screen and (-webkit-min-device-pixel-ratio:0) {
body {
background: blue;
}
}
/*
By placing a pound(#) symbol at the beginning of a CSS property,
it will be ignored by all browsers except Internet Explorer.
This works as a general hack that will cover all versions of IE.
*/
body {
background: red;
#background: blue;
}
/*
An underscore(_) at the beginning of a CSS property works just
like the pound(#) symbol with the exception that it will target IE6 only.
*/
body {
background: red;
_background: blue;
}
/*
An asterisk(*) works just like the underscore with the exception
that it is only read in Internet Explorer 7.
*/
html > body {
background: red;
*background: blue;
}
* html h1 {} targets IE 6
html > body h1 {} targets IE 7 and later
h1 {*property:value;} targets IE 7 and below
html > body h1 {*property:value;} targets IE 7 only
/*
Placing a pound(#) symbol at the end of a CSS property group will
cause all properties within that group and anything after the
pound symbol to be ignored. This does NOT work in Safari 3.
*/
body {
background: blue;
}
body {
background: red;
#
}
h1 {
/* This style will also be ignored by Safari 2 */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment