HTML Comments

HTML Comments

HTML comments are used to add notes, explanations, or temporarily disable parts of the code without affecting the rendering of the webpage. Comments are not displayed in the browser. They are enclosed within special delimiters:

Syntax:

    <!-- Write comment Here--> 

Characteristics:

  • Ignored by the browser: Comments do not appear in the rendered page.
  • Multi-line comments: Comments can span multiple lines.
  • Nested comments not allowed: You cannot nest comments inside other comments. For example:
      <!-- This is a <!-- nested comment --> 
    This will break the comment and result in invalid HTML.

Important Notes:

  • Avoid leaving sensitive information in comments, as they are visible in the source code when viewed in a browser.
  • Use comments sparingly to keep the codebase clean and readable.
Previous Next