How to write stylesheets specifically for Internet Explorer

Posted by : Leo T Abraham on 3 September, 2013

At different stages of development, we might have come across style issues associated with IE. It was always a problem for most of the HTML developers. How can we solve that issue, without causing problem in other browsers. The only way to do is, write stylesheets specifically for IE. We are having the provision to write styles specifically for IE. In the following code you can change the versions according to your need.

If you want to write style for IE8 use the following:

<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="ie8specific.css" />

If you want to write style for IE 7 and lower versions use the following:

<!--[if lt IE 8]>
    <link rel="stylesheet" type="text/css" href="ie7-and-down.css" />

If you want to write style for  IE 7 and higher versions use the following:

<!--[if gte IE 7]>
    <link rel="stylesheet" type="text/css" href="ie7-and-up.css" />

If you want to use inline CSS for IE, then instead of linking to a CSS file, add styles in between the condtion.

<!--[if gte IE 7]>
        // Style for IE 7 and higher versions.


user image
Mohammed Sajin
Great. Really Helpful. Keep up Dokie :)