33. Working around IE bugs

33. Working around IE bugs

Sometimes the only way to make something work in both IE and more standards-compliant browsers is to write separate code for each. Use only as a last resort.

Conditional comments in HTML
safest, recommended by MS, but somewhat inconvenient
<!--[if IE]> HTML for IE <![endif]-->
<!--[if !IE]>--> HTML for non-IE <!--<![endif]-->
Use these with <link ...> to load alternate stylesheet files.
Selector hacks in CSS
take advantage of IE parsing bugs. Easier for small things, but more prone to unexpected side effects in the future.
IE 6 and below
* html ... /* the "star html hack" or "Tan hack" */
IE 7 only
*:first-child+html ...
IE 7 and non-IE
html>body ...
non-IE only
html>/**/body ...
Ken Keys, CAIDA, 2006-12-01