views:

53

answers:

3

Do conditional comments behave as expected across browsers? Can they cause rendering bugs or other issues?

Are there any errors in the formatting/syntax of this CC?

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="718" height="227" id="swf">
    <param name="movie" value="images/swf.swf" />
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="images/swf.swf" width="718" height="227">
    <!--<![endif]-->
        <img src="images/alt.jpg" border="0" width="718" height="227">
    <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
</object>
+2  A: 

Conditional CSS comments are specific to IE on windows. See what wikipedia has to say.

If used correctly, they will be interpreted as regular comments in other browsers. It really depends on how you are using them.

The example you posted will not work correctly, as you are supposed to wrap the whole conditionals in an HTML comment.

Wrong:

<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="images/swf.swf" width="718" height="227">
<!--<![endif]-->
    <img src="images/alt.jpg" border="0" width="718" height="227">
<!--[if !IE]>-->
</object>
<!--<![endif]-->

Right:

<!--[if !IE]>
<object type="application/x-shockwave-flash" data="images/swf.swf" width="718" height="227">
<![endif]-->
    <img src="images/alt.jpg" border="0" width="718" height="227">
<!--[if !IE]>
</object>
<![endif]-->
Oded
The wiki article states that it is a valid alternative downlevel-revealed conditional comment. There is also another alternative syntax. Which one is most commonly used by devs and reflects current standards? Thx!
John Himmelman
@John Himmelman - The safest and most used (that I have seen) is downlevel-hidden.
Oded
+2  A: 

Conditional comments are just HTML comments, they cannot affect other browsers because they are treated as what they are. Only IE will recognize a conditional comment.

Andy E
+1  A: 

Do conditional comments behave as expected across browsers?
From my experience, yes. (IE only as others have said)

Can they cause rendering bugs or other issues?
No, not the comments themselves. The code within, possibly, but to the same extent any code can cause rendering bugs or other issues.

Are there any errors in the formatting/syntax of this CC?
Not that I can see, easiest way is to test it.

Kerry