Android
Selector Hacks
WebKit
.selector:not(*:root) {}
JavaScript Hacks
var isChromium = !!window.chrome;
Media Query Hacks
@media screen and (min-width:0\0) {}
Chrome
Selector Hacks
WebKit
.selector:not(*:root) {}
Supports Hacks
@supports (-webkit-appearance:none) {}
Property/Value Hacks
.selector { (;property: value;); }.selector { [;property: value;]; }
JavaScript Hacks
var isChromium = !!window.chrome;
Webkit
var isWebkit = 'WebkitAppearance' in document.documentElement.style;
var isChrome = !!window.chrome && !!window.chrome.webstore;
Media Query Hacks
@media \\0 screen {}
@media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution: .001dpcm) { .selector {} }
Firefox
Selector Hacks
body:empty .selector {}
body:last-child .selector, x:-moz-any-link {}
Media Query Hacks
@media \0 all {}
Selector Hacks
body:last-child .selector, x:-moz-any-link, x:default {}
body:not(:-moz-handler-blocked) .selector {}
Media Query Hacks
@media screen and (-moz-images-in-menus:0) {}
@media screen and (min--moz-device-pixel-ratio:0) {}
Selector Hacks
_::-moz-progress-bar, body:last-child .selector {}
Media Query Hacks
@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) {}
@media all and (min--moz-device-pixel-ratio:0) { @media (min-width: 0px) {} }@media all and (-moz-images-in-menus:0) { @media (min-width: 0px) {} }
Supports Hacks
@supports (-moz-appearance:meterbar) {}
Selector Hacks
_::-moz-range-track, body:last-child .selector {}
Supports Hacks
@supports (-moz-appearance:meterbar) and (display:flex) {}
@supports (-moz-appearance:meterbar) and (cursor:zoom-in) {}
@supports (-moz-appearance:meterbar) and (background-attachment:local) {}
@supports (-moz-appearance:meterbar) and (image-orientation:90deg) {}
@supports (-moz-appearance:meterbar) and (all:initial) {}
@supports (-moz-appearance:meterbar) and (list-style-type:japanese-formal) {}
Media Query Hacks
@media all and (min--moz-device-pixel-ratio:0) and (min-resolution: 3e1dpcm) {}
Supports Hacks
@supports (-moz-appearance:meterbar) and (background-blend-mode:difference,normal) {}
JavaScript Hacks
var isFF = !!window.sidebar;
Selector Hacks
_:-moz-tree-row(hover), .selector {}
JavaScript Hacks
var isFF = 'MozAppearance' in document.documentElement.style;
var isFF = !!navigator.userAgent.match(/firefox/i);
var isFF = typeof InstallTrigger !== 'undefined';
var isFF = !!window.globalStorage;
var isFF = /a/[-1]=='a';
var isFF = (function x(){})[-6]=='x';
var isFF = (function x(){})[-5]=='x';
Miscellaneous
@-moz-document url-prefix() {}
Selector Hacks
Everything but Firefox and Internet Explorer ≤8
_::selection, .selector:not([attr*='']) {}
Internet explorer/edge
Supports Hacks
@supports (-webkit-appearance:none) {}
Selector Hacks
.unused-class can be any unused class
* html .selector {}.unused-class.selector {}
Everything but Internet Explorer 6
html > body .selector {}
*:first-child+html .selector {}.selector, x:-IE7 {}*+html .selector {}body*.selector {}
.selector\ {}
.selector, {}
Everything but Internet Explorer ≤7
html > /**/ body .selector {}head ~ /**/ body .selector {}
Everything but Firefox and Internet Explorer ≤8
_::selection, .selector:not([attr*='']) {}
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*='']) {}
Property/Value Hacks
.selector { _property: value; }.selector { -property: value; }
.selector { property: value\9; }.selector { property/*\**/: value\9; }
Acts as an !important; string after ! can be anything
.selector { property: value !ie; }
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; }
Media Query Hacks
@media screen\9 {}
@media \0screen\,screen\9 {}
@media \0screen {}
@media screen and (min-width:0\0) {}
Selector Hacks
_:-ms-input-placeholder, :root .selector {}
_:-ms-fullscreen, :root .selector {}
Media Query Hacks
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {}
Everything but Internet Explorer and Safari ≤6
@media screen { @media (min-width: 0px) {} }
JavaScript Hacks
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;
var isIE = document.all && document.compatMode;
var isIE = !!window.ActiveXObject;
var isIE = document.all && !window.XMLHttpRequest;
var isIE = document.all && window.XMLHttpRequest && !document.querySelector;
var isIE = document.all && window.XMLHttpRequest;
var isIE = document.all && !document.querySelector;
var isIE = navigator.appVersion.indexOf("MSIE 7.") !== -1;
var isIE = document.all && document.querySelector && !document.addEventListener;
var isIE = document.all && document.querySelector;
var isIE = document.all && !document.addEventListener;
var isIE = '\v'=='v';
var isIE = !+'\v1';
var isIE = document.all && !window.atob;
var isIE = document.all && document.addEventListener && !window.atob;
var isIE = document.all && document.addEventListener;
var isIE = /*@cc_on!@*/false;
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 = document.all && window.atob;
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;
Conditional comments
<!--[if IE 6]> Internet Explorer 6 <![endif]--><!--[if IE 7]> Internet Explorer 7 <![endif]--><!--[if IE 8]> Internet Explorer 8 <![endif]--><!--[if IE 9]> Internet Explorer 9 <![endif]-->
<!--[if lte IE 6]> Internet Explorer 6 or less <![endif]--><!--[if lte IE 7]> Internet Explorer 7 or less <![endif]--><!--[if lte IE 8]> Internet Explorer 8 or less <![endif]--><!--[if lte IE 9]> Internet Explorer 9 or less <![endif]-->
<!--[if gte IE 6]> Internet Explorer 6 or greater <![endif]--><!--[if gte IE 7]> Internet Explorer 7 or greater <![endif]--><!--[if gte IE 8]> Internet Explorer 8 or greater <![endif]--><!--[if gte IE 9]> Internet Explorer 9 or greater <![endif]-->
Everything but Internet Explorer ≤9
<!--[if !IE]><!--> Everything but Internet Explorer ≤9 <!--<![endif]-->
<!--[if IE]> Internet Explorer 9- <![endif]-->
Opera
Selector Hacks
WebKit
.selector:not(*:root) {}
Supports Hacks
@supports (-webkit-appearance:none) {}
Property/Value Hacks
.selector { (;property: value;); }.selector { [;property: value;]; }
JavaScript Hacks
var isChromium = !!window.chrome;
Webkit
var isWebkit = 'WebkitAppearance' in document.documentElement.style;
Selector Hacks
html:first-child .selector {}
JavaScript Hacks
var isOpera = /^function \(/.test([].sort);
Selector Hacks
_:-o-prefocus, body:last-child .selector {}
@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {}
JavaScript Hacks
Replace X by the version
var isOpera = window.opera && window.opera.version() == X;
var isOpera = !!window.opera;
Media Query Hacks
@media (min-resolution: .001dpcm) { _:-o-prefocus, .selector {} }
JavaScript Hacks
var isOpera = !!window.opera || /opera|opr/i.test(navigator.userAgent);
Selector Hacks
*|html[xmlns*=""] .selector {}
Media Query Hacks
@media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution: .001dpcm) { .selector {} }
Opera mini
JavaScript Hacks
var isOperaMini = Object.prototype.toString.call(window.operamini) === '[object OperaMini]';
var isOperaMini = (navigator.userAgent.indexOf('Opera Mini') > -1);
Safari
Selector Hacks
WebKit
.selector:not(*:root) {}
Supports Hacks
@supports (-webkit-appearance:none) {}
Property/Value Hacks
.selector { (;property: value;); }.selector { [;property: value;]; }
JavaScript Hacks
Webkit
var isWebkit = 'WebkitAppearance' in document.documentElement.style;
Media Query Hacks
@media screen and (min-width:0\0) {}
Everything but Internet Explorer and Safari ≤6
@media screen { @media (min-width: 0px) {} }
Selector Hacks
html:first-child .selector {}
html[xmlns*=""] body:last-child .selector {}html[xmlns*=""]:root .selector {}
*|html[xmlns*=""] .selector {}
_::-moz-svg-foreign-content, :root .selector {}
JavaScript Hacks
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" && !window.chrome;
Media Query Hacks
@media \\0 screen {}