Reputation: 502
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 //
works in some programming languages?
Upvotes: 19
Views: 148916
Reputation: 1407
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.
Upvotes: 0
Reputation: 2783
Reason of comments:
HTML Comments
<!-- Everything is invisible -->
Upvotes: -1
Reputation: 247
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.
Upvotes: 4
Reputation: 19
Just create a multi-line comment around it. When you want it back, just erase the comment tags.
For example, <!-- Stuff to comment out or make inactive -->
Upvotes: 1
Reputation: 1453
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.
Upvotes: 0
Reputation: 9469
HTML Comments:
<!-- <div> This div will not show </div> -->
CSS Comments:
/* This style will not apply */
JavaScript Comments:
// This single line JavaScript code will not execute
OR
/*
The whole block of JavaScript code will not execute
*/
Upvotes: 15
Reputation: 522155
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. :)
Upvotes: 37