Home / Articles / Programming languages / Markup languages / HTML & CSS / Conditional comments for IE

Conditional comments for IE

Conditional comments for IE
 
Conditional comments for IE
  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 5/5 (1 votes cast)

Thank you for rating!

You have already rated this page, you can only rate it once!

Your rating has been changed, thanks for rating!

Log in or create a user account to rate this page.


Conditional comments are used to write special instructions that only work in Internet Explorer below version 5.

Conditional comment looks like this:

<!-[if IE]> Here place special instructions for IE. <![endif]-->

The structure is similar to a usual comment in HTML, therefor all other browsers will see it as a normal comment. Explorer recognizes the special syntax <!--[if IE]>, resolves the if and parses the content of the conditional comment as if it were a normal page content. Conditional comments use the syntax of HTML comments, so they can only be included in the HTML page. It is convenient to put special styles for IE and paste the "link" tag in the conditional comments.

Below are given several conditional comments that show the version of Internet Explorer, you are using.

<!--[if IE]> Instructions for Internet Explorer <![endif]-->
<!--[if IE 5]> Instructions for IE 5 <![endif]-->
<!--[if IE 5.0]> Instructions for IE 5.0 <![endif]-->
<!--[if IE 5.5]> Instructions for IE 5.5 <![endif]-->
<!--[if IE 6]> instructions for IE 6 <![endif]-->
<!--[if IE 7]> Instructions for IE 7 <![endif]-->

In the conditional comments, you can use conditional statements in which you can specify a more complex condition. The table below lists all the operators.

Conditional statements 

Description

lt 

less than

lte

less than or equal

gt  

greater than

gte

greater than or equal

And some examples:

<!--[if ! IE 5]> Instructions for IE 5.5, 6, or 7 <![endif]-->
<!--[if gt IE 5.0]> Instructions for IE 5.5, 6, or 7 <![endif]-->
<!--[if lte IE 5.5]> Instructions for IE 5.0 or 5.5 <![endif]-->
<!--[if gte IE 6]> instructions for IE 6 or 7 <![endif]-->
<!--[if lt IE 7]> Instructions for IE 5.0, 5.5, or 6 <![endif]-->

 

Read also

Details about "float" property

Details about "float" property

How to write in HTML

How to write in HTML

Discussion (total 1 comments)

GottZ
October 08, 2014 at 07:14 am
var ie = /*@cc_on !@*/false;

Post comment

basicuse.net
html5_css
106160485398655174790

Quick navigation

General navigation