Microsoft has fixed much of the bugs that plagued IE6 and in the process removed the filters we used to target Internet Explorer in our CSS. As Lord God Martha would say, this is a good thing.
However, there will be a time when you need to send a rule to IE7 and not to IE6. Or perhaps you need to send a rule to IE7 and to IE6. Iâ€™ve put together a test page of IE6 hacks to see what IE7 doesnâ€™t walk right past. Iâ€™m condensing the test page into the paragraph below.
Luckily, there is a loophole for us and we can use this for â€œoffroad use only.â€ Why am I using this silly description? Because you and I need to move beyond hacks. Place browser specific (IE) in conditional comments or use a serverside script to place a class on the HTML or body (HTML class=â€ie6â€³ ) to target these browsers in your main CSS file.
However, these hacks will let you develop your CSS on the fly and fix your issues before going the proper route.
Test Paragraph (condensed version of test page)
this is the test paragraph to see how IE7 will handle hacks
- IE7 Beta2 understands #wrap>p.borderfun and applies correct color.
- IE7 Beta2 ignores * HTML p.borderfun styles.
- IE7 Beta2 recognizes the * hack.
- IE7 Beta2 ignores the underscore hack.
- In Firefox, Safari, and Opera, you should see a red border. In IE7, you should see a black border. In IE6, you should see a pink border.
How to use this
If you need to send something to IE6 and nothing else: use the underscore attribute hack (_border:1px solid pink;) If you want to send something to IE7 AND IE6, use the *attribute hack (*border:1px solid black;). If you want to send something to IE7 and NOT IE6, use a combination (*border:1px solid black; _border:1px solid pink;).
A call to arms
Get out there kids and begin removing your * HTML rules. Place those suckers in a conditional commented CSS file or at least begin replacing them with the underscore hack. When it comes time to tune for IE7, youâ€™ll have less work to do.
— This was originally published on tdrake.net