Browserhacks is an extensive list of browser specific CSS and JavaScript hacks from all over the interwebs. Press the first letter of a browser to jump to the according section, like F for Firefox.
Please keep in mind using a hack is not always the perfect solution. It can be useful to fix some weird browser specific bug, but in most cases you should fix your CSS/JS or use feature detection.
var isChromium = !!window.chrome;
@media screen and (min-width:0\0) {}
.selector { (;property: value;); }
.selector { [;property: value;]; }
var isChromium = !!window.chrome;
Webkit
var isWebkit = 'WebkitAppearance' in document.documentElement.style;
var isChrome = !!window.chrome && !!window.chrome.webstore;
@media \\0 screen {}
@media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution: .001dpcm) {}
var isFF = !!window.sidebar;
var isFF = 'MozAppearance' in document.documentElement.style;
var isFF = !!navigator.userAgent.match(/firefox/i);
var isFF = !!window.globalStorage;
var isFF = typeof InstallTrigger !== 'undefined';
var isFF = /a/[-1]=='a';
var isFF = (function x(){})[-6]=='x';
var isFF = (function x(){})[-5]=='x';
body:empty .selector {}
.selector, x:-moz-any-link {}
.selector, x:-moz-any-link, x:default {}
body:not(:-moz-handler-blocked) .selector {}
@media \0 all {}
@media screen and (-moz-images-in-menus:0) {}
@media screen and (min--moz-device-pixel-ratio:0) {}
@media all and (min--moz-device-pixel-ratio:0) and (min-resolution: .001dpcm) {}
@media all and (-moz-images-in-menus:0) and (min-resolution: .001dpcm) {}
@-moz-document url-prefix() {}
.selector { _property: value; }
.selector { -property: value; }
Any combination of these characters: ! $ & * ( ) = % + @ , . / ` [ ] # ~ ? : < > |
.selector { !property: value; }
.selector { $property: value; }
.selector { &property: value; }
.selector { *property: value; }
.selector { )property: value; }
.selector { =property: value; }
.selector { %property: value; }
.selector { +property: value; }
.selector { @property: value; }
.selector { ,property: value; }
.selector { .property: value; }
.selector { /property: value; }
.selector { `property: value; }
.selector { [property: value; }
.selector { ]property: value; }
.selector { #property: value; }
.selector { ~property: value; }
.selector { ?property: value; }
.selector { :property: value; }
.selector { |property: value; }
Acts as an !important; string after ! can be anything
.selector { property: value !ie; }
.selector { property: value\9; }
.selector { property/*\**/: value\9; }
var isIE = document.all && !window.XMLHttpRequest;
var isIE = document.all && document.compatMode;
var isIE = document.all && !document.querySelector;
var isIE = document.all && window.XMLHttpRequest && !document.querySelector;
var isIE = document.all && window.XMLHttpRequest;
var isIE = document.all && document.querySelector;
var isIE = document.all && !document.addEventListener;
var isIE = document.all && document.querySelector && !document.addEventListener;
var isIE = document.all && !window.atob;
var isIE = document.all && document.addEventListener && !window.atob;
var isIE = document.all && document.addEventListener;
var isIE = document.all && window.atob;
var isIE = /*@cc_on!@*/false;
Check for Internet Explorer version
var ieVersion = /*@cc_on (function() {switch(@_jscript_version) {case 1.0: return 3; case 3.0: return 4; case 5.0: return 5; case 5.1: return 5; case 5.5: return 5.5; case 5.6: return 6; case 5.7: return 7; case 5.8: return 8; case 9: return 9; case 10: return 10;}})() || @*/ 0;
Check for Internet Explorer version
var ieVersion = (function() { if (new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})").exec(navigator.userAgent) != null) { return parseFloat( RegExp.$1 ); } else { return false; } })();
var isIE = navigator.appVersion.indexOf("MSIE 7.") !== -1;
var isIE = '\v'=='v';
var isIE = !+'\v1';
var isIE = eval("/*@cc_on!@*/false") && document.documentMode === 10;
var isIE = document.body.style.msTouchAction !== undefined;
var isIE = window.navigator.msPointerEnabled;
var isIE = 'behavior' in document.documentElement.style && '-ms-user-select' in document.documentElement.style;
var isIE = '-ms-scroll-limit' in document.documentElement.style && '-ms-ime-align' in document.documentElement.style;
.selector, x:-moz-any-link {}
.selector, x:-moz-any-link, x:default {}
.unused-class can be any unused class
* html .selector {}
.unused-class.selector {}
.selector, {}
*:first-child+html .selector {}
.selector, x:-IE7 {}
*+html .selector {}
body*.selector {}
.selector\ {}
.selector\ {}
Everything but Internet Explorer 6
html > body .selector {}
Everything but Internet Explorer 7-
html > /**/ body .selector {}
head ~ /**/ body .selector {}
Everything but Internet Explorer 8-
:root * > .selector {}
body:last-child .selector {}
body:nth-of-type(1) .selector {}
body:first-of-type .selector {}
.selector:not([attr*='']) {}
_:-o-prefocus, .selector {}
@media screen\9 {}
@media \0screen\,screen\9 {}
@media \0screen {}
@media screen and (min-width:0\0) {}
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {}
Everything but Internet Explorer and Safari
@media screen { @media (min-width: 0px) {} }
<!--[if IE]> Internet Explorer <![endif]-->
Not Internet Explorer
<![if !IE]> Not Internet Explorer <![endif]>
<!--[if IE X]> Internet Explorer X <![endif]-->
<!--[if lte IE X]> Internet Explorer X or less <![endif]-->
<!--[if gte IE X]> Internet Explorer X or greater <![endif]-->
<!--[if (IE X)|(IE Y)]> Internet Explorer X or Internet Explorer Y <![endif]-->
<!--[if (gte IE X)&(lte IE Y)]> Internet Explorer between X and Y (included)<![endif]-->
Conditional classes
<!--[if lt IE 7]> <html class='ie ie6 lte9 lte8 lte7'> <![endif]-->
<!--[if IE 7]> <html class='ie ie7 lte9 lte8 lte7'> <![endif]-->
<!--[if IE 8]> <html class='ie ie8 lte9 lte8'> <![endif]-->
<!--[if IE 9]> <html class='ie ie9 lte9'> <![endif]-->
<!--[if gt IE 9]> <html> <![endif]-->
<!--[if !IE]><!--> <html> <!--<![endif]-->
.selector { (;property: value;); }
.selector { [;property: value;]; }
var isChromium = !!window.chrome;
Webkit
var isWebkit = 'WebkitAppearance' in document.documentElement.style;
var isOpera = /^function \(/.test([].sort);
var isOpera = !!window.opera;
Replace X by the version
var isOpera = window.opera && window.opera.version() == X;
var isOpera = !!window.opera || /opera|opr/i.test(navigator.userAgent);
html:first-child .selector {}
_:-o-prefocus, .selector {}
@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {}
*|html[xmlns*=""] .selector {}
@media (min-resolution: .001dpcm) { _:-o-prefocus, .selector {} }
@media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution: .001dpcm) {}
.selector { (;property: value;); }
.selector { [;property: value;]; }
Webkit
var isWebkit = 'WebkitAppearance' in document.documentElement.style;
var isSafari = /a/.__proto__=='//';
var isSafari = /constructor/i.test(window.HTMLElement);
var isSafari = !!navigator.userAgent.match(/safari/i) && !navigator.userAgent.match(/chrome/i) && typeof document.body.style.webkitFilter !== "undefined";
html:first-child .selector {}
html[xmlns*=""] body:last-child .selector {}
html[xmlns*=""]:root .selector {}
*|html[xmlns*=""] .selector {}
@media screen and (min-width:0\0) {}
Everything but Internet Explorer and Safari
@media screen { @media (min-width: 0px) {} }
Browserhacks is mostly based on the big list of CSS browser hacks by Paul Irish. Other posts like Moving IE specific CSS to media blocks by Keith Clark, Detecting browsers with JS hacks by Gareth Eyes and IE CSS hacks by Nicolas Gallagher greatly helped.
By the way, thanks a lot to Jeff Clayton who helped us with tests. If you'd like to contribute too, please hit us on GitHub.
You may also want to have a look at these related resources: