I’ve come to accept and support conditional comments as a tool to use when it’s otherwise impossible to get Internet Explorer to behave desirably. To me, they’re much more acceptable than unstable CSS hacks or extensive
!important declarations. They’re much easier to maintain, and it’s the only truly reliable way to target not only Internet Explorer itself, but specify a version as well. The subject of conditional comments comes with great debate that seems to be ongoing. There are good arguments on both sides, but to me, conditional comments seem like the best solution.
When I use conditional comments
Up until this point, conditional comments have saved the day for me simply by being present in the
head of my documents. For nearly every client project, I find myself using conditional comments to target both Internet Explorer 6 as well as Internet Explorer 7. In my opinion, as far as standards compliance is concerned, IE7 is merely a shuffle forward, as opposed to a step.
Using conditional comments in the
Until recently, it hadn’t even occurred to me that using conditional comments in the
body of your document could become commonplace. There’s no documentation specifying that conditional comments can be used only in the
head of your document, so why stop there? To me, using conditional comments in the
body of your document is partially counter productive.
The reason I choose to employ conditional comments is their nature of providing longevity. By writing specific style sheets to target specific versions of Internet Explorer, I’m able to solve a rendering issue and leave the solution as is for the life of the document. The problem is solved with a minimal change to the DOM.
When you choose to use conditional comments in the
body of your document, you’re electing to alter the DOM in a more significant way. Now, instead of working with different style sheets to solve a problem, you’re altering the problem itself. If this route is chosen, you now have a number of choices. You can alter a significant portion of the DOM in order to work with a single, existing style sheet, or you can take both sides and use conditional comments to include Internet Explorer specific style sheets as well as alter the DOM at the same time.
What’s your opinion?
How do you feel about conditional comments in the first place? If you’re opposed, is it due to the fact that the code is technically proprietary? Is it due to the fact that the implementations you’ve seen are as outlined above in that conditional comments are littered across the entire DOM?