HTML Comments
HTML Comment tags are used to insert some useful comments in the HTML document.
Anything you write inside Comment tags will be ignored by web browser and it will not show any output to the user. Comments are very helpful for programmers. Using HTML Comments, you can add some useful description of some code. They help you understand your code and increases code readability later.
Example of Comment tag: <!-- This is a sample comment -->
<!-- Add any comment about following paragraph -->
<p>This is a first paragraph.</p>
<!-- This comment will tell something about following paragraph -->
<p>This is a another paragraph for testing.</p>
Note:
Note: There is an exclamation sign (!) in the opening tag, but not in the closing tag.
Complete HTML Program with Multi-line HTML Comments
You can simply use multiple lines to add large comments using the same tags. See multi-line comment example below:
<html>
<head>
<title>Multiline Comments Testing</title>
</head>
<body>
<!--
This is a multiline comment and you can
add some description about the following
code so that it will be helpful for others.
-->
<p>This is some sample text.</p>
</body>
</html>
Conditional Comments
Conditional comments define HTML tags to be executed by Internet Explorer only.
<!--[if IE 8]>
.... some HTML or code here only for Internet Explorer ....
<![endif]-->
Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments |
---|
No Content Found. |
Interview Questions & Answers |
---|
How to add Comments in HTML? |