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 tag, i.e., -->. 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 your browser.


<!-- This is a commented code -->


<!DOCTYPE html>

        <title>Example for comment.</title>
    <!-- Body of webpage starts from here -->

        <h2>This is HTML comment example</h2>
        <p>This is my first <strong>paragraph text</strong>.</p>


Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram