The comment tag (<!– Comment –>) is used to insert comments in the HTML code. It is a good practice of coding so that coder and the reader can get help to understand the code. It is helpful to understand the complex code. The comment tag is useful during the debugging of codes.
- It is a simple piece of code that is wiped off (ignore) by web browsers i.e, not displayed by the browser.
- It helps the coder and reader to understand the piece of code used for especially in complex source code.
<!-- Comments here -->
Types of HTML Comments: There are three types of comments in HTML which are:
- Single-line comment
- Multi-lines comment
- Using <comment> tag
Output: Here you can see the single-line comment. Single line comment will not display in the output.
Multi-line comment: Multiple lines can be also used by using the (<!– –>).
Output: Here we can see that in the comment section we have used multiple lines but still it’s not printed.
Using <comment> tag: There used to be an HTML <comment> tag, but it is not supported by any modern browser.
Note: The <comment> tag is not supported by modern browsers.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML course.