Monday, April 11, 2011

HTML IE conditional comments

TASK: 
Tell special instructions for IE.

SOLUTION: 

<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->

EXPLANATION: 

  1. Their basic structure is the same as an HTML comment (<!-- -->). Therefore all other browsers will see them as normal comments and will ignore them entirely.
  2. Explorer Windows, though, has been programmed to recognize the special <!--[if IE]> syntax, resolves the if and parses the content of the conditional comment as if it were normal page content.
  3. Since conditional comments use the HTML comment structure, they can only be included in HTML files, and not in CSS files. I'd have preferred to put the special styles in the CSS file, but that's impossible. You can also put an entire new <link> tag in the conditional comment referring to an extra style sheet.

The syntax I use is:

<!--[if IE]>
According to the conditional comment this is Internet Explorer<br />
<![endif]-->


<!--[if IE 6]>
According to the conditional comment this is Internet Explorer 6<br />
<![endif]-->


<!--[if IE 7]>
According to the conditional comment this is Internet Explorer 7<br />
<![endif]-->


<!--[if gte IE 6]>
According to the conditional comment this is Internet Explorer 6 and up<br />
<![endif]-->
<!--[if lt IE 6]>
According to the conditional comment this is Internet Explorer lower than 6<br />
<![endif]-->


<!--[if lte IE 6]>
According to the conditional comment this is Internet Explorer lower or equal to 6<br />
<![endif]-->


<!--[if gt IE 6]>
According to the conditional comment this is Internet Explorer greater than 6<br />
<![endif]-->

Note the special syntax:
  • gt: greater than
  • gte:greater than or equal to
  • lt:less than
  • lte: less than or equal to



1 comment:

  1. Men's MBT Karani Shoes present you with each one of all those wellbeing many benefits freed from you procuring to allocate more time for you to get the work executed out! It is possible to forget with regards to gonna this membership, consuming training training, as well as handling as well as walking through your own neighborhood. Mbt shoes could make your own entire body harder in addition to much healthier quickly despite the fact that sporting these folks in the period of your own frequent timetable.

    ReplyDelete