The HTML comment is a text between the start tagand the end tag .
It is important to note that the start tag contains an exclamation mark () but not the end tag.
The HTML comments are not displayed on web pages and are kept hidden. While rendering the source code, browsers hide them on the front end.
HTML comments help create small notes within the HTML document.
While working in a team, other developers can understand your code easily with a hint from these notes.
We also use comments to explain the functionality and purpose of the block of code.
HTML comments help build, debug, or redesign a website.
In previous chapters, you have already seen our examples where we have commented on some codes to explain the functionality and purpose.
Let's see an example of an HTML comment. Click on 'Result on Editor' to view the output of the code.
You notice that the browser has completely ignored the comments while displaying the web page.
HTML comments can really be useful in maintaining code version history.
There can be scenarios where you want to add some new functionality in the coming days and you want yourself to remind the same when next time you view your code. You simply write a reminder as a comment in your HTML code.
Sometimes we can also comment out a few lines of code to temporarily hide the content of a few tags. See the example below.
The content of the HTML comment element can extend to multiple lines and such a comment in HTML is referred to as a multiline HTML comment.
The need for the multiline comment arises when we want to provide a more detailed description regarding the section of the code for future reference.
Let's see an example of a multiline HTML comment.
Many a time we come across a situation where we need to hide only a part of the content or code from a single line of HTML code. Such comments are referred to as inline HTML comments.
See an example.
|1. HTML Tutorial|
|2. Introduction to HTML|
|3. Basic HTML Page|
|4. HTML Editors|
|5. Web Browser|
|6. HTML History|
|7. Basic HTML Tags|
|8. HTML Elements|
|9. HTML Attributes|
|10. HTML Headings|
|11. HTML Paragraphs|
|12. HTML Text Formatting|
|13. HTML Styles|
|14. HTML Comment|
|15. HTML Quotation|
|16. HTML Colors|
|17. HTML RGB Colors|
|18. HTML HEX Colors|
|19. HTML HSL Color|
|20. HTML CSS|
|21. HTML Links|
|22. HTML Link Colors|
|23. Link within Page|
|24. HTML Images|
|25. HTML Background Image|
|26. HTML Image Map|
|27. HTML Picture Element|
|28. HTML Favicon|
|29. HTML Table|
|30. HTML Table Border|
|31. HTML Table Size|