How to make HTML code inactive with comments

后端 未结 7 975
慢半拍i
慢半拍i 2020-12-15 06:00

I have some HTML code on a page that I don\'t want to erase, but make inactive for the short term. How can I make the browser ignore parts of the page in the same way the

相关标签:
7条回答
  • 2020-12-15 06:24

    To comment block with nested comments: substitute inner (block) comments from "--" to "++"

    <!-- *********************************************************************
         * IMPORTANT: To uncomment section
         *            sub inner comments "++" -> "--" & remove this comment
         *********************************************************************
    <head>
       <title>My document's title</title> <++! My document's title ++>
       <link rel=stylesheet href="mydoc.css" type="text/css">
    </head>
    
    <body>
    <++! My document's important HTML stuff ++>
    ...
    ...
    ...
    </body>
    
    *********************************************************************
    * IMPORTANT: To uncomment section
    *            sub inner comments "++" -> "--" & remove this comment
    *********************************************************************
    -->
    

    Thus, the outer most comment ignores all "invalid" inner (block) comments.

    0 讨论(0)
  • 2020-12-15 06:28

    Behold HTML comments:

    <!-- comment -->
    

    http://www.w3.org/TR/html401/intro/sgmltut.html#idx-HTML

    The proper way to delete code without deleting it, of course, is to use version control, which enables you to resurrect old code from the past. Don't get into the habit of accumulating commented-out code in your pages, it's no fun. :)

    0 讨论(0)
  • 2020-12-15 06:29

    Reason of comments:

    1. Comment out elements temporarily rather than removing them, especially if they've been left unfinished.
    2. Write notes or reminders to yourself inside your actual HTML documents.
    3. Create notes for other scripting languages like JavaScript which requires them

    HTML Comments

    <!-- Everything is invisible  -->
    
    0 讨论(0)
  • 2020-12-15 06:35

    If you are using Eclipse then the keyboard shortcut is Ctrl + Shift + / to add a group of code. To make a comment line or select the code, right click -> Source -> Add Block Comment.

    To remove the block comment, Ctrl + Shift + \ or right click -> Source -> Remove Block comment.

    0 讨论(0)
  • 2020-12-15 06:36

    Use:

    <!-- This is a comment for an HTML page and it will not display in the browser -->
    

    For more information, I think 3 On SGML and HTML may help you.

    0 讨论(0)
  • 2020-12-15 06:41

    HTML Comments:

    <!-- <div> This div will not show </div> -->
    

    See Reference

    CSS Comments:

    /* This style will not apply */
    

    See Reference

    JavaScript Comments:

    // This single line JavaScript code will not execute
    

    OR

    /*
       The whole block of JavaScript code will not execute
    */
    

    See Reference

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