Now I'm trying to i...">

How do you get IE 6 Conditional Comments?

I have this markup that works great:

<div id="hd1" class="header headerNotIE6"> 

Now I'm trying to install a specific workaround ie6, so I try to use only this div if the browser is not IE 6. So I want this line to get if it is IE7, 8 and firefox and chrome. I tried this, but it does not work in Firefox or Chrome.

 <!--[if !(IE 6)]> <div id="hd1" class="header headerNotIE6"> <![endif]--> 

is there a conditional comment "if everything except IE6" that works in the html file?

0
source share
2 answers

To target any IE other than IE6, you use the operator ! :

 <!--[if !IE 6]> <div id="hd1" class="header headerNotIE6"> <![endif]--> 

To target any IE except IE6 , as well as all other browsers , you need a special syntax to break out of conditional comments so that other browsers can read and parse HTML inside and not see the entire block as one comment:

 <!--[if !IE 6]><!--> <div id="hd1" class="header headerNotIE6"> <!--<![endif]--> 

The original syntax shown in voyager's answer , known as open-level syntax, does not contain additional comment delimiters. However, this is not valid HTML, so you must use the above syntax to preserve the validity of the document.

+3
source

You need

 <![if !IE 6]> <div id="hd1" class="header headerNotIE6"> <![endif]> 

Non-IE browsers see <!--[if !IE 6]><div id="hd1" class="header headerNotIE6"><![endif]--> as a regular comment, so they never see inside div

0
source

All Articles