如何在HTML代码中评论/取消注释 [英] How to comment/uncomment in HTML code
问题描述
通常在使用html编码视图模板时,我添加一些有用的注释的习惯在测试时会耗费大量的时间。
考虑这段代码...
<! - 这里开始侧边栏 - >
< div id =sidebar>
....
< / div>
<! - 这里启动主内容窗格 - >
< div id =main-contents>
...
< / div>
<! - 这里开始页脚 - >
< div id =footer>
...
< / div>
现在,如果我必须隐藏视图模板的某个部分,只需选择所需的代码并放入单行注释(大部分时间使用快捷键)。然而,在只有块注释工作的html代码中,我最终删除了所有结束注释标记( - >),直到我想要注释的位置发生 - 像这样......
<! - 这里开始边栏
< div id = 栏 >
....
< / div>
<! - 这里启动主内容窗格
< div id =main-contents>
...
< / div>
<! - 这里开始页脚
< div id =footer>
...
< / div> - >
然后当我完成测试时,我必须经历那些结束标记的痛苦。
在HTML中使用块注释有更好更省时的方法吗?
取决于扩展名。如果是.html,您可以使用<?
开始,
Often while coding view templates in html, my habit of adding some helpful comments causes lots of time-consuming effort while testing.
Consider this code...
<!-- Here starts the sidebar -->
<div id="sidebar">
....
</div>
<!-- Here starts the main contents pane -->
<div id="main-contents">
...
</div>
<!-- Here starts the footer -->
<div id="footer">
...
</div>
Now, if I have to hide out some portion of the view template, in case of php I would just select the desired code and put single-line comments (using a shortcut key most of the times).
However, in html code, where only the block comments work, I end-up removing all the closing comment tags (-->) till the position I want the commenting to occur - something like this...
<!-- Here starts the sidebar
<div id="sidebar">
....
</div>
<!-- Here starts the main contents pane
<div id="main-contents">
...
</div>
<!-- Here starts the footer
<div id="footer">
...
</div>-->
Then when I'm done testing I have to go through the agony of putting back those closing tags.
Is there a better and time saving way of block commenting in HTML?
Depends on the extension. If it's .html, you can use <?
to start and ?>
to end a comment. That's really the only alternative that I can think of. http://jsfiddle.net/SuEAW/
这篇关于如何在HTML代码中评论/取消注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!