tags:

views:

332

answers:

4

What i want is that i want this portion of html code to be hidden from IE6 and IE7 but not firefox, opera or IE8 but conditional comments not working properly on this portion....I am using separate CSS with conditional comments in the head section But conditional comments for opera are not working and also sometimes Firefox shows strange behaviour

<!--[if gte IE 8]>
    <[if Gecko]>


 <div class="anythingSlider">

      <div class="wrapper">
        <ul>
           <li>
                <img src="gallery/1.jpg" alt="" />
           </li>
            <li>
                <img src="gallery/2.jpg" alt="" />
           </li>

        </ul>
     </div>
 </div>

     <[endif]>
<[endif]––>
+1  A: 

you're looking at something like this:

<!--[if lt IE 7]>
      <div class="wrapper">
        <ul>
           <li>
                <img src="gallery/1.jpg" alt="" />
           </li>
            <li>
                <img src="gallery/2.jpg" alt="" />
           </li>
<![endif]-->

AFAIK you don't specify browsers individually. This "hack" is only valid for IE.

Michal M
Actually the problem was when i used conditional comments to hide it from ie6 and ie7, it also hides the same portion in Firefox 3.5. so i was not getting anywhere. I found the solution like this<![if IE 8]> <div class="anythingSlider"> <div class="wrapper"> </div> <![endif]>This is working in Opera, IE8, IE6, IE7, and Firefox and Safari too... I think when you do the -- thing, it make the whole portion commented and firefox 3.5 doesn't show it......when i removed -- from comments, it worked fine.....
Muhammad Ahsan
+2  A: 

There's no such thing as:

<[if Gecko]>

Conditional comments only work for IE, so you can only distinguish between IE5, IE6, IE7, IE8 and [all other browsers]. (Luckily, it's usually only IE6 and maybe IE7 you need to sniff for!)

i want this portion of html code to be hidden from IE6 and IE7

OK, to show the contents of a conditional comment not just on the tested condition but also on [all other browsers], you need a downlevel-revealed conditional comment:

<!--[if gte IE 8]><!-->
    <div class="anythingSlider">
        ...
    </div>
<!--<![endif]-->

(Note this is not quite the official MS syntax for a downlevel-revealed CC, because that would be invalid HTML.)

bobince
you are right downlevel revelead comments worked fine, i figured it out like this.....<![if IE 8]> <div class="anythingSlider"> <div class="wrapper"> </div> <![endif]>This is working fine in all IE versions, Opera, Firefox and SafariThanks in anyway.
Muhammad Ahsan
Please try the syntax as above. It should work just the same, but it's also valid HTML, and will work as expected in a future IE9.
bobince
A: 

Hiding actual HTML content from specific browsers is a step towards a world of complication and a maintenance nightmare. A better approach would be to adopt Progressive Enhancement. However, if you really want to hide content, you could used display: none; in the IE6/7 style sheet that is loaded via a <!--[if lt IE 8]> CSS file conditional comment.

Andrew Mason
A: 

bobince right.

Also, you can hide content only from IE.

<!--[if !IE]><!--> IE won't see it. <!--<![endif]-->
NV