Creating comments

suggest change

HTML comments can be used to leave notes to yourself or other developers about a specific point in code. They can be initiated with <!-- and concluded with -->, like so:

<!-- I'm an HTML comment! -->

They can be incorporated inline within other content:

<h1>This part will be displayed <!-- while this will not be displayed -->.</h1>

They can also span multiple lines to provide more information:

<!-- This is a multiline HTML comment.
  Whatever is in here will not be rendered by the browser.
  You can "comment out" entire sections of HTML code.

However, they cannot appear within another HTML tag, like this:

<h1 <!-- testAttribute="something" -->>This will not work</h1>

This produces invalid HTML as the entire <h1 <!-- testAttribute="something" --> block would be considered a single start tag h1 with some other invalid information contained within it, followed by a single \> closing bracket that does nothing.

For compatibility with tools that try to parse HTML as XML or SGML, the body of your comment should not contain two dashes --.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents