Comments are an essential part of HTML; it helps to provide the details of what is written in the HTML source code. HTML comment tags are completely ignored to display by the browsers. It's used to insert comments into the source code.
- When more than one developer works on the same application or web page, HTML comments can help understand the source code.
- Comment can be used anywhere to add information about HTML, which will help developers easily understand the existing code in the future.
Writing Comments in HTML
For writing comments in HTML, they begin with the
-- (starting comment tag) and end with the close comment
-->. Comments in HTML can appear when
someone tries to view the page's source code, but nothing is
rendered within the comment tag when you run the web page through
<!-- This is a commented code -->
<!DOCTYPE html> <html> <head> <title>Example for comment.</title> </head> <!-- Body of webpage starts from here --> <body> <h2>This is HTML comment example</h2> <p>This is my first <strong>paragraph text</strong>.</p> </body> </html>