Skip to content
uencoder

HTML Comment

An HTML comment uses <!-- ... --> to wrap explanatory text that is not rendered, used for documentation notes and conditional comments.

Purpose

To add developer notes or conditional resource loading (IE conditional comments) to HTML without affecting rendering.

Mechanism

Content between <!-- and --> is ignored by the browser and not rendered. IE conditional comments <!--[if IE]>...<![endif]--> execute conditionally in old IE. Comments cannot nest, and -- is not allowed inside.

Use cases

  • HTML document comments
  • IE conditional comments
  • Template comments

Related tools

References