Assuming some HTML like this...
<section>
<h1>Some stuff</h1>
<!-- That was some stuff... -->
</section>
I add comment tags around the HTML I want to comment out. I want to comment out everything, but the comment is closed by existing comment.
<!--
<section>
<h1>Some stuff</h1>
<!-- That was some stuff... -->
</section>
-->
What is the best way to handle this scenario without losing all my inline comments.
Look for shortcuts in your editor to do nested comments in html. This can with one keypress (un)comment a block of code and do a substitution of <! -- inner-comment --> to <!~~ inner-comment ~~> (just like guido's answer suggests), making commenting and uncommenting blocks just as easy as it is in other languages.
--...--> Tag.
The HTML Comment Tag Comments in HTML start with <! -- and end with --> . Don't forget the exclamation mark at the start of the tag! But you don't need to add it at the end.
A HTML comment start with a <!--
and ends at the first -->
encountered. There's no way to change this behavior. If you want to hide a large section with may contains comments during the development, you can wrap in a <div style="display:none"></div>
. But don't do that in production, it's bad.
To comment block with nested comments: sub inner (block) comments from "--" to "~~"
<!-- *********************************************************************
* IMPORTANT: to uncomment section
* sub inner comments "~~" -> "--" & remove this comment
*********************************************************************
<head>
<title>my doc's title</title> <~~! my doc's title ~~>
<link rel=stylesheet href="mydoc.css" type="text/css">
</head>
<body>
<~~! my doc's important html stuff ~~>
...
...
...
</body>
*********************************************************************
* IMPORTANT: to uncomment section
* sub inner comments "~~" -> "--" & remove this comment
*********************************************************************
-->
thus, outer most comment ignores all "invalid" inner (block) comments
As far as I know, there is no way to block that. You need to be careful what you are commenting out or not.
See : http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.4
What you can try is to use PHP to comment out HTML code... Hope it helped!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With