The Best Guide to HTML Comments

Knowing the ins and outs of HTML is essential for any successful web developer. In this guide, we will introduce you to comments—one of the key components of this programming language. A comment is a string of code that a web browser ignores. They are used for the same reason as comments in any other language. For example, comments can make code more understandable and readable. They are very useful if someone else has to work on a code you’ve written, as they can use the comments to understand your code faster.

HTML Comments

The comment tag is used to insert comments in the HTML code. The comments are not visible to the user; they are used to explain the code.

Syntax: <!-- Comments -->

Full Stack Java Developer Course

The Gateway to Master Web DevelopmentExplore Course
Full Stack Java Developer Course

Types of HTML Comments

There are two types of comments:

  • Single-line comment
  • Multi-line comment

Single-Line Comment

single_line_comment-html_comments

output_single_line

Notice that the text inside the comments is not displayed on the web page.

Free Course: Programming Fundamentals

Learn the Basics of ProgrammingEnroll Now
Free Course: Programming Fundamentals

Multi-Line Comments

In a multi-line comment, the comments are written in multiple lines. They are not included in the final web page.

multi_line_comment

output_multi_lines

Get skilled in HTML5 and CSS3 with the Full Stack Java Developer Master's Program. Click to check out the program details!

Conclusion

In this article, we have learned about  HTML comments. We demonstrated how both types of comments are added into HTML code and explained their functions. To get up to speed on HTML, we recommend getting certified, and Simplilearn’s Full Stack Java Developer will help you master web development. The course will cover everything you need to learn about front-end, middleware, and back-end Java web developer technologies. You will learn to build an end-to-end application, test and deploy code, store data using MongoDB, and much more.

If you have any questions, please feel free to ask them in our comments section, and our experts will answer them promptly.

About the Author

Taha SufiyanTaha Sufiyan

Taha is a Research Analyst at Simplilearn. He is passionate about building great user interfaces and keeps himself updated on the world of Artificial Intelligence. Taha is also interested in gaming and photography.

View More
  • Disclaimer
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.