IE Specific Stylesheets

Everybody who codes, knows how hard it is to get your template to be valid and display correctly in every browser. In other words, Cross-browser coding.

Today we're mostly talking about IE, since thats the browser that gives most coders the problems. The code below, when used correctly will only display that stylesheet to the specified IE version.

Alot people ask, do i need a special stylesheet, or do I have to rewrite my stylesheet, the anwser is simple. No. All you have to do is correct certain things to work with IE. mabe add an !important here and there.

All depends on what the display problem is. If there was no IE, everything would be alot easier dont you think

Here is the 'codes' to use inside your <body> tag, depending on which IE your going to specify.


IE - Generic:

CODE
&lt;!--[if IE]&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;ie.stylesheet.css&quot; /&gt;
&lt;![endif]--&gt;



IE - Spicific Version:

CODE
&lt;!--[if IE 6]&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;ie.6.stylesheet.css&quot; /&gt;
&lt;![endif]--&gt;




Heres a list.
- [if IE] - if above or equal to version 5
- [if IE 6] - if equal to version 6
- [if lt IE 6] - if less than version 6
- [if lte IE 6] - if less than or equal to version 6
- [if gt IE 6] - if greater than version 6
- [if gte IE 6] - if greater than or equal to version 6

You can specify what version that you want the stylesheet to take place on by changing the number inside the if IE area. If we wanted, we could change it to 5, 6, or 7. Just look up the list of version for IE.

Now if you wanted to you could add anything else inside that if IE tag area. It could be some html, an image, php, javascript, whatever you would like. But it would only display to that version of IE specifed, if any.

Cite: You much also put your regular stylesheet inside the top <body> tag for non-ie browsers. Dont forget that.

Monday September 10, 2007 - 775 reads