tags:

views:

152

answers:

6

Hi! I'm just wondering if it's possible to comment out IE conditional comments themselves (for testing purposes)? The following does not work:

<!-- <!--[if IE 7]> some code <![endif]--> -->

Thanks in advance! flexx

+6  A: 

No, it isn't possible.

SGML/HTML/XML/XHTML comments cannot be nested.

David Dorward
so, it's not possible without making them invalid (newtover's suggestion)... thanks!
flexx
A: 

If I were you I'd use a template systems like Template Toolkit and then Just include or exclude the comment conditionally, based on some variable you could set at runtime.

Template Toolkit http://template-toolkit.org/

xenoterracide
I'll check that out... thx
flexx
+5  A: 

I think you can just insert something to make them invalid:

<!--\[if IE 7]> some code <!\[endif]-->
newtover
A: 

If you are sending that through a server such as .asp or aspx then of course you could comment that out server side.

James Westgate
+2  A: 
<!--[if IE 70]> some code <![endif]-->

:)

toscho
A: 

You can't nest comments, but you can comment them out by adding an extra <!-- to the beginning. Your example from above changes from <!-- <!--[if IE 7]> some code <![endif]--> --> to <!-- <!--[if IE 7]> some code <![endif]-->. Just take out the extra --> and it should comment out that pesky conditional.

Tested successful in Firefox 3.5.2 and IE 7.0.5730.13CO

Voyagerfan5761