How to comment/uncomment in HTML code

前端 未结 11 1649
名媛妹妹
名媛妹妹 2020-12-28 13:39

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...

相关标签:
11条回答
  • 2020-12-28 13:48

    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/

    0 讨论(0)
  • 2020-12-28 13:50

    Eclipse Juno has a good way for it. You just do the cmd+/

    0 讨论(0)
  • 2020-12-28 13:53

    The following works well in a .php file.

    <php? /*your block you want commented out*/ ?>
    
    0 讨论(0)
  • 2020-12-28 13:53

    /* (opener) */ (closer)

    for example,

    <html>
     /*<p>Commented P Tag </p>*/
    <html>
    
    0 讨论(0)
  • 2020-12-28 13:56

    Depending on your editor, this should be a fairly easy macro to write.

    • Go to beginning of line or highlighted area
    • Insert <!--
    • Go to end of line or highlighted area
    • Insert -->

    Another macro to reverse these steps, and you are done.

    Edit: this simplistic approach does not handle nested comment tags, but should make the commenting/uncommenting easier in the general case.

    0 讨论(0)
  • 2020-12-28 13:57

    I find this to be the bane of XML style document commenting too. There are XML editors like eclipse that can perform block commenting. Basically automatically add extra per line and remove them. May be they made it purposefully hard to comment that style of document it was supposed to be self explanatory with the tags after all.

    0 讨论(0)
提交回复
热议问题