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?
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.
Type "---" followed by ">" (no quotes and no spaces) at the end of the block of text you want to hide. This closed comment tag ensures that the HTML code between the open comment tag and this point will be hidden when viewed with an Internet browser.
To hide an element, set the style display property to “none”. document.
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. :)
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
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