I hate trying to resolve CSS and Javascript conflicts between web browsers. What I hate even worse is going about it in an "unclean" way.
Conditional comments for IE have been around a long time and I haven't really seen too many people (if any) using them for resolving style bugs. Check out what I do on every web site I build.
<link href="/public/css/style.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 7]>
<link rel="stylesheet" type="text/css" href="/public/css/style-ie.css" />
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="/public/css/style-ie6.css" />
<![endif]-->
Note that I normally don't bother with IE 5.5, but this could work for that as well. With these CSS links in place, I can simply expect a normal, sane style sheet to be included on well-behaved browsers, a special style sheet for IE7, and an even more "special" style sheet for IE6. Since these are declared in order of insanity, (from least to greatest) I can simply copy style declarations from my original style sheet, override whatever I need to, and keep everything squeaky clean.
There's my solution. If anyone reading still uses CSS hacks, I would love to know why. It may be something I just don't "get."

Recent Comments