Fixing Internet Explorer CSS Problems with Conditional Comments

You’ve developed a site using W3C best practices; it validates, the markup’s semantic or as clean as possible, and looks great in Firefox. The problem is, Internet Explorer doesn’t quite see it as the designer intended. The CSS is out and in need of a few hacks; but there’s a better, more effecient and tidier solution – conditional comments.

<!--[if lte IE 7]>
<link rel="stylesheet" type="text/css" href="css/ie.css" media="screen" />
<![endif]-->

The above piece of code targets selects all IE versions less than or equal to 7, and is Microsoft’s recommended method for aiming CSS as one of its browsers.  Include all the problematic CSS in stylesheet ‘ie.css’ and leave the conditional comment below the main stylesheet. Try this rather than resorting to a hack, or giving up entirely and whacking a table in.

Tags: , , , ,

Leave a Reply