CSS Filters and Hacks for Browsers

January 23rd, 2007 2 Comments »

Came across 2 great articles on CSS filters and hacks for various browsers. One is available at BTreeHugger’s Blog and another one is available at Mezzoblue, whose author happens to be Dave Shea, the creator of CSS Zen Garden. For anyone who developed IE6-centric CSS for corporate intranets or mainstream audience, the articles presented some great hacks in case you need to target certain CSS rules just for IE7, Firefox, or Safari, and validate CSS 3 at the same time.

To target IE7 only, simply prepend *:first-child+html to your selector as:
*:first-child+html div {...rules...}

To target Firefox/Gecko only, just prepend *> to your selector as:
*>div {...rules...}

To target Safari/Webkit/KHTML only, simply prepend body:last-child:not(:root:root) to your selector as:
body:last-child:not(:root:root) div {...rules...}