How to write comments and character entities

Write a comment

Browsers do not display comments, but developers can see them in page source.

<!-- Main navigation -->
<nav>...</nav>

<!-- TODO: add the contact address -->

Use comments well

  • Explain a non-obvious decision, not every tag
  • Keep comments current when code changes
  • Do not nest comments
  • Never place passwords, private notes, or secrets in comments

Represent reserved characters

An entity starts with & and ends with a semicolon. Use one when a character would otherwise be parsed as markup.

<p>Use &lt;h1&gt; for the main heading.</p>
<p>Tea &amp; coffee cost &pound;5.</p>
<p>&copy; 2026 Example</p>

Prefer readable text

UTF-8 lets you type most characters directly, such as é or £. Entities remain useful for <, >, and &; use a non-breaking space only when a line break would genuinely harm meaning.