IE7The two main ones for me are conditional comments and the “first-child+html” fix found by Mark Hammond.

Conditional Comments

Conditional comments are small scripts that you place in your HTML. They check for the version of IE being used, and include whatever you put between the comments if conditions are satisfied. Here’s an example:

<!--[if IE 7]>
 Include my IE7 only stylesheet here.
<![endif]-->

Personally, I tend to stay well away from conditional comments. The idea of putting small scripts within HTML comments makes me shudder. It’s also basically a simple form of browser sniffing, and really, I don’t want to go back to those days thank you very much.

The “first-child+html” workaround

For now, my solution of choice is a little bit of CSS trickery to target IE7 specifically. I’ve used this workaround on this very site. I was having trouble with the logo being too close to the top of the window in IE7. What I wanted was to add an extra 20px of padding to the top of the logo in IE7 only:

#menuBar {
  float: right;
  display: inline;
  width: 240px;
}
   /* For IE7 */
   *:first-child + html #menuBar {
     padding-top: 20px;
   }

This worked a treat, and is perfect for the small fixes I need right now.

Mark Hammond goes on to note that this fix only reliably works when your page starts with a doctype and html element together (which is 99% of the time I would bet).

This of course exploits a bug in IE7, so there is no guarantee it will work in future updates. For now though, it provides the quick fixes I need until I can explore the browser further.

Who knows of any other workarounds for IE7? I’d be interested to hear how you are fixing your sites up to work with Microsoft’s latest.