HTML Comments

Comments are notes in your code that the browser ignores.

Comments are useful for explaining a section to yourself or teammates, and for temporarily hiding markup while you work.

Writing a Comment

A comment

<!DOCTYPE html>
<html>
<body>

<!-- This is a comment and won't be shown -->
<p>This paragraph will be shown.</p>

</body>
</html>

How They Work

  • A comment starts with <!-- and ends with -->.
  • Anything between those markers is skipped by the browser.
  • Comments can span multiple lines.
Note: Comments are visible to anyone who views your page source, so never put passwords or secrets in them.

Exercise: HTML Comments

How do you write a comment in HTML?