August 17, 2024
HTML Comment
If you want to write some notes in your HTML file which you do not want to show on the webpage but want to include in your HTML file for better understanding your code. So for it you can create comments in HTML. These comments present in your file but, these all will be ignored by the browser. You can start HTML comments with <!-- And ends with --> sign and you can write your text between these signs. You can also comment your HTML code with HTML comments. Example of HTML comments is mentioned below:
<!-- HTML very easy to learn -->
If you include above mentioned example in your HTML file so it will not show in your browser. It will just work like notes in your HTML file.
There is another reason, why you use comments. Sometimes it happens that you use JavaScript in your HTML file and for some reason JavaScript does not support by browser in that case you should use HTML comment for perfect function of your HTML file. Example is mentioned below:
Example
<script>
<!--
document.write("HTML is very easy to learn!");
-->
</script>
Suppose if above mentioned JavaScript will not work in any condition then it converts automatically in comments. And it will not appear in your browser.