Skip to content

How to create a comment in HTML

Find out how to add comments to an HTML page

A comment in an HTML page is a bit of HTML that is not interpreted by the browser.

A comment is included between the <!-- and the --> tags:

<!-- a comment -->

Comments can also span over multiple lines:

comment -->

You can use comments in HTML for yourself, to indicate for example why some HTML is present.

You can also use them to remove portion of HTML you wrote but now you don't want to display. For testing purposes, perhaps.

In both cases, the person visiting the site will not see the text you commented in the rendered page, but comments are still visible if they try to view the source of the page.

So, don't keep anything secret or anything you don't want users to see in there.

Plus, remember that page size matters for speed, so you should not have lots of comments in your HTML in production. Little comments are fine, I am more talking about hundreds lines of commented HTML.

→ Download my free HTML Handbook!



You might be interested in those things I do:

  • Learn to code in THE VALLEY OF CODE, your your web development manual
  • Find a ton of Web Development projects to learn modern tech stacks in practice in THE VALLEY OF CODE PRO
  • I wrote 16 books for beginner software developers, DOWNLOAD THEM NOW
  • Every year I organize a hands-on cohort course coding BOOTCAMP to teach you how to build a complex, modern Web Application in practice (next edition February-March-April-May 2024)
  • Learn how to start a solopreneur business on the Internet with SOLO LAB (next edition in 2024)
  • Find me on X

Related posts that talk about html: