CSS Filters and Hacks for Browsers
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...}
2 Responses to “CSS Filters and Hacks for Browsers”
Leave a Reply
You must be logged in to post a comment.
January 23rd, 2007 at 10:33 pm
Be careful; your second one isn’t strictly true. I am working on adding some new rules to my brand new CSS hack list (my latest article). The second rule only works at Mezzoblue because he is using a cascading effect, but the rule you wrote “as is” will apply to a lot of browsers including Macintosh IE5 and many others. My blog has a more in-depth set of Gecko engine hacks (not to toot my own horn or anything), including ones that target Firefox 1 and ones that target 1.5 up (or Mozilla-like browsers using those versions of Gecko).
Be aware that I am also going to likely going to be changing my hacks shortly to reflect the data I found in my latest article.
January 24th, 2007 at 11:56 am
Hi, BTreeHugger. Thank you for pointing out the potential pitfall of my use of the CSS rule from Mezzoblue. It was meant to be a quick fix for pages that were developed awhile back without the Strict Doctype nor the lang attribute in the HTML element. Your CSS hacks for Mozilla-like browsers work wonderfully otherwise. I was glad to find your blog (and the hacks =)), and will certainly look forward to your updated versions. Keep me posted!