Cascading Style Sheets/Hacks and Filters

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Browser Specific Filters[edit | edit source]

Opera 10+ CSS Filter

 .dude:read-only { color: green; } 
 .dude:read-write /* form elements */

IE6/IE7 CSS Filter

 @media, { .dude { color: silver;} }

IE7 CSS Filter

 *:first-child+html #mytag to target IE7

IE8 CSS Filter

 @media all { .dude { color: brown\0/; } }

IE9 CSS Filter

 @media all and (monochrome: 0) { .dude { color: pink\9; } }

Webkit CSS Filter

 * > /**/ .dude, x:-webkit-any-link { color:red; } /* * > /**/ hides from IE7; remove if unneeded */

Konqueror CSS Filter

 * > /**/ .dude, x:-khtml-any-link { color:red; }  /* * > /**/ hides from IE7; remove if unneeded */

Safari 2 CSS Filter

 html body:only-child .dude

Firefox CSS Filter

 @-moz-document url-prefix() { .dude { color: green; }

Firefox 3.6+ CSS Filter

 @-moz-document url-prefix() { @media -moz-scrollbar-start-backward { .dude { color: green; } }

Firefox 3.0+ CSS Filter

 @-moz-document url-prefix() { .dude:-moz-system-metric(scrollbar-start-backward) { color: green; } }

Legacy Browser Hacks[edit | edit source]

All web browsers are not equal and different rendering of the same code, even if the code is validated, can destroy a web page's presentation. To work around this a large community of browser hacks has been developed. These hacks should be avoided at all cost because they may break one's code in other browsers or slow down performance. However sometimes it is impossible to avoid the use of all of these hacks.

Be aware that constant browser updates may cause hacks to not work in the future.

  • Caio Hack — hides rules from Netscape 4, even 'inline' CSS