HTML Comments

Photo by DATAIDEA

Comments

HTML comments are text, phrases or sentences inside an HTML file.

They are only shown in codes and not rendered by a browser.

Why use HTML comments?

HTML comments help both beginners and experienced web developers to easily organize their codes.

They act like sticky notes in HTML files

How to write HTML comments

An HTML comment starts with <!-- and ends with -->. It looks like this:

<!-- comments go here -->

Example

See the Pen HTML_comments by DATAIDEA (@DATAIDEA) on CodePen.

On the example given above, you have learned that you make a single-line and multi-line of HTML comments.

And if you have noticed we have also put comments beside a start tag and end tag.

That is for us to easily recognize where a specific element starts and ends.

To be among the first to hear about future updates of the course materials, simply enter your email below, follow us on (formally Twitter), or subscribe to our YouTube channel.

Back to top