Target IE Specificly in HTML/CSS Using Conditional Comments

Out of all the most popular browsers used, Internet Explorer (IE) renders HTML and CSS with the most issues. In most cases, there are fixes for IE that can be implemented by using some different CSS properties. However, sometimes it is important to make a call specifically to Internet Explorer telling the browser what to render, and in some cases, what not to render.

To make an explicit call to the Internet Explorer browser, use:

<!--[if IE]> 

Special instructions for IE here 

<![endif]-->
<!--[if IE 7]> 

Special instructions for IE 7 here 

<![endif]-->
<!--[if gt IE 6]> 

Special instructions for versions of IE greater than 6 here 

<![endif]-->
<!--[if gte IE 6]> 

Special instructions for versions greater than or equal to IE 6 here 

<![endif]-->
<!--[if lt IE 9]> 

Special instructions for versions less than IE 9 here 

<![endif]-->
<!--[if lte IE 9]> 

Special instructions for versions less than or equal to IE 9 here 

<![endif]-->

Lastly, you can target all browsers that are not Internet explorer using conditional comments as well:

<!--[if !IE]> 

Special instructions for browsers that are not Internet Explorer 

<![endif]-->

I hope this helps some of you that are looking for some help with cross browser compatibility. IE can be difficult but by using conditional comments, it makes cross browser testing a lot easier.

Advertisements