Topic: Conditional Comments or Hacks?

This is not a right or wrong thread, just two way of doing things and the reason for that.

So hacks are bad - most of us agree. A hack is a code style that takes advantage of bugs and mistakes in browsers. If the browser is fixed, the hack does not work and the site is likely broken.

Discussing this in another forum a comment was made that rings true and should be mentioned here. So a few points to consider:

Hack

Con - Requires a mistake or bug in a browser to work, it that is fixed the hack fails.


Con - Makes the CSS not valid


Pro - A hack is placed alone in the CSS, when the CSS is external this means you need but remove it from the style sheet to be rid of it.




Condition Comments


Con - They have to be placed in your markup, every single page...


Con - They muck up pure structured code & invalidate your code


Con - You are playing to the whims of the most popular browser yes, but you are writing incorrect code due to one single user agent out of the dozens that you may have visit
your site, logical to cater to one single broken user agent?


Pro - You are creating styles for IE in a form that only IE will read leaving your CSS pure for standards based browsers.


Conclusion
The choice is yours, would you rather have pure structure or pure CSS?

Would you rather write a hack in a single document or would you rather write a comment/s in every page of your site? Course with the smart use of Templates or includes you can limit this.

So this is not a do or do not, simply consider this and what comments will follow and make an informed decision whether to use Hacks or Comments. IE7 has improved but there are still some problems with IE7 and Opera 9 and a whole new series of Hacks will be needed. IE7 has blocked the * html hack which was often used to correct Layout problems in IE, however those layout problems have not been corrected, they still exist bit the hack does not.

Re: Conditional Comments or Hacks?

roll