Targeting Different Browsers with CSS & Conditional Comments

Simply put, every web developer must deal with browser inconsistency’s. Fortunately CSS hacks are very much a thing of the past, and there are better solutions to cross browser compatibility. My method of choice is Internet Explorer’s conditional comments. These allow for the separation of Explorer specific code from “valid” code.

XHTML


CSS (ie.css)

/* General ------------------------------------*/
.clearfix
{
    zoom:1;
}
/* IE6 ----------------------------------------*/
* html body
{
	background:red;
}
/* IE7 ----------------------------------------*/
div > p
{
	background:blue;
}

How it works

Conditional comments only work in Internet Explorer. This allows us to give special instructions for only Explorer. They are supported from Explorer 5 onwards, and it is even possible to distinguish between 5.0, 5.5 and 6.0.

Related Links

Comments

No comments have been added yet.

Leave a Reply

By submitting a comment here you grant Fresh Tilled Soil a perpetual license to reproduce your words and name/web site in attribution. Inappropriate comments will be removed at admin's discretion.