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
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
No, it isn't possible.
SGML/HTML/XML/XHTML comments cannot be nested.
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/
I think you can just insert something to make them invalid:
<!--\[if IE 7]> some code <!\[endif]-->
If you are sending that through a server such as .asp or aspx then of course you could comment that out server side.
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