This article is about a CSS hacking technique. Not to be confused with the proprietary Microsoft-specific CSS property.
A CSS filter is a coding technique used to hide or show CSS markup depending on the browser, version number, or capabilities. Browsers have different interpretations of CSS behavior and different levels of support for the W3C standards. CSS filters are sometimes used to achieve consistent layout appearance in multiple browsers that do not have compatible rendering.
Most browsers have CSS tags that apply to that browser only, or at least to the underlying render engine. The prefix on these tags are specific to each rendering engine. Here is an example.
Trident-ms- — All experimental properties are prefixed with "-ms-", e.g. -ms-interpolation-mode instead of interpolation-mode.
Gecko-moz- — All experimental selectors, properties and values are prefixed with "-moz-", e.g. ::-moz-selection instead of ::selection.
WebKit-webkit- — All experimental selectors, properties and values are prefixed with "-webkit-", e.g. -webkit-box-shadow instead of box-shadow.
KHTML-khtml- — All experimental selectors, properties and values are prefixed with "-khtml-", e.g. -khtml-opacity instead of opacity.
-xv- — All new selectors, properties and values introduced by CSS3 Speech Module are prefixed with "-xv-" (but not found in CSS2 aural style sheets), e.g. -xv-voice-rate instead of voice-rate.
-o- — All experimental properties are prefixed with "-o-", e.g. -o-transition-property instead of transition-property.
The DOM properties corresponding to vendor-specific experimental CSS properties are prefixed with the vendor-prefix, without any hyphens.
This hack exploits a bug in Internet Explorer for Mac related to comment parsing. A comment ending in \*/ is not properly closed in IE Mac, so rules that need to be ignored in IE Mac can be placed after such a comment. Another comment is needed after the rule to close the comment for IE Mac.
Box model hack
Called the "box model hack" because the bug it is most often used to work around is the Internet Explorer box model bug, this hack provides a different set of properties to Internet Explorer and other browsers. As of version 6, IE has corrected the box model bug in documents which include certain Document Type Declarations (required by the HTML specifications) in certain ways.
The first voice-family statement is set to the string "}", but an IE parser bug will interpret it as a string with a single backslash followed by a closing brace for the end of the rule. voice-family is chosen because it will not affect rendering on a screen style sheet. The second rule uses the html>body hack for browsers such as Opera 5 that have the parsing bug but do not have the box model bug (and, additionally, which support the child selector).
Versions 6 and below of Internet Explorer recognize properties with this prefix (after discarding the prefix). All other browsers ignore such properties as invalid. Therefore, a property that is preceded by an underscore or a hyphen is applied exclusively in Internet Explorer 6 and below.
This hack uses invalid CSS and there are valid CSS directives to accomplish a similar result. Thus some people do not recommend using it. On the other hand this hack does not change the specificity of a selector making maintenance and extension of a CSS file easier.
Versions 7 and below of Internet Explorer recognize properties which are preceded by non-alphanumeric characters except an underscore or a hyphen (after discarding the prefix). All other browsers ignore such properties as invalid. Therefore, a property that is preceded by an non-alphanumeric character other than an underscore or a hyphen, such as an asterisk, is applied exclusively in Internet Explorer 7 and below.
This hack uses invalid CSS and there are valid CSS directives to accomplish a similar result. On the other hand, this hack doesn't change the specificity of a selector making maintenance and extension of a CSS file easier.
Star HTML hack
The html element is the root element of the W3C standard DOM, but Internet Explorer versions 4 through 6 include a mysterious parent element. Fully compliant browsers will ignore the * html selector, while IE4-6 will process it normally. This enables rules to be specified for these versions of Internet Explorer which will be ignored by all other browsers. For example, this rule specifies text size in Internet Explorer 4-6, but not in any other browsers.
Although Internet Explorer 7 no longer recognizes the classic star HTML hack, it has introduced a similar hack using selectors new to IE7:
This code will be applied in Internet Explorer 7, but not in any other browser. Note that this hack only works in IE7 standards mode; it does not work in quirks mode. This hack is also supported by Internet Explorer 8's compatibility view (IE7 standards mode), but not in IE8 standards mode. Like the star HTML hack, this uses valid CSS.
Child selector hack
Internet Explorer 6 and earlier do not support the "child selector" (>), allowing rules to be specified for all other browsers. For example, this rule will turn paragraph text blue in Firefox, but not in IE before version 7.
Although IE7 added support for the child selector, a variation of the hack has been discovered which allows Internet Explorer 7 to be excluded as well. When an empty comment occurs immediately after the child selector, IE7 will drop the rule that follows, as will earlier versions of IE.
Negation pseudo-class hack
Internet Explorer 8 and below do not support the CSS3 :not()negation pseudo-class. Internet Explorer 9 added support for CSS3 pseudo-classes including the negation pseudo-class.
The negation pseudo-class accepts any simple selector: A type selector, universal selector, attribute selector, class selector, ID selector, or pseudo-class. (excluding pseudo-elements and the negation pseudo-class itself).  It then applies the following properties to all elements which do not match this argument. Note that the ie8andbelow selector has no meaning, it is simply a string that will never match an actual selector. The string dummy would work equally as well.
A variation of this hack uses the :root pseudo-class, which is also unrecognized by Internet Explorer 8 and below.
The :empty pseudo-class, introduced in CSS3, is supposed to select only elements which do not contain any content. However, Gecko 1.8.1 and below (used in Firefox 2.0.x and below) incorrectly selects body:empty even when the body element contains content (which it usually should). This can be taken advantage of to feed exclusive CSS rules to Firefox 2.0.x and below, along with other browsers using the same rendering engine.
This hack uses valid CSS.
Internet Explorer 7 and below have a few quirks related to the !important declaration, which is supposed to give a value higher importance than normal. IE7 and earlier accept virtually any string in place of important and process the value normally, while other browsers will ignore it. This can be used to specify values exclusively for these browsers.
Similarly, IE7 and earlier accept non-alphanumeric characters after an !important declaration, while other browsers will ignore it.
Both of these hacks use invalid CSS. Internet Explorer 6 and below also have a problem with !important declarations when the same property of the same element has another value specified within the same code block, without another !important declaration. This should result in the second value being overridden by the first, but IE6 and lower do not honor this.
This hack uses valid CSS.
Between versions 5 and 7, Internet Explorer has supported a proprietary syntax for applying CSS properties which change dynamically, sometimes referred to as CSS expressions. Dynamic properties are typically combined with other hacks to compensate for unsupported properties in older versions of Internet Explorer.
Conditional comments are conditional statements interpreted by Microsoft Internet Explorer in HTML source code.
Hiding code using hacks often leads to pages being incorrectly displayed when browsers are updated. Many hacks that used to hide CSS from Internet Explorer 6 and lower no longer work in version 7 due to its improved support for CSS standards. The Microsoft Internet Explorer development team have asked that people use conditional comments instead of hacks.
Comparison of layout engines (Cascading Style Sheets)