HTML Tags

HTML Comment Tag

HTML comments are used to insert notes or explanations in the HTML code that are not displayed in the browser.
Comments are helpful for developers to document code, temporarily disable code, or leave reminders.

Syntax

<!-- This is a comment -->

Attributes

The HTML comment tag does not support any attributes. Only the content inside <!-- --> is recognized as a comment.

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>HTML Comment Example</title>
</head>
<body>
  <h2>HTML Comment Example</h2>

  <!-- This is a comment and will not be displayed in the browser -->
  <p>This paragraph is visible to the user.</p>

  <!-- 
    Multiple line comment:
    1. This is a note for developers.
    2. Can temporarily disable code.
  -->
  <p>This paragraph is also visible.</p>
</body>
</html>

Output

Browser Output

There is no visible output for HTML comments.
Comments only exist in the HTML source and are ignored by the browser when rendering the page.

Browser Support

Chrome
Chrome
Firefox
Firefox
Edge
Edge
Safari
Safari
Opera
Opera
IE
IE9+
✅Yes✅Yes✅Yes✅Yes✅Yes✅Yes

Comments do not appear in the rendered page, but they are visible in the page source.

Notes

  • Comments can be used for code documentation, debugging, or temporarily removing code.
  • Nested comments are not allowed; HTML does not support <!-- <!-- nested --> -->.
  • Avoid leaving sensitive information in comments, as they are visible in the page source.

Conclusion

The HTML comment tag is a developer-only tool for leaving notes or disabling code temporarily. It does not affect the visual layout of the page and is fully supported in all browsers.

Sign In Form

User your email and password to singn in

Don’t have an account, signup here : 

HTML5 & CSS3

Tools and Tutorials

Want a Website

Want a website for your business ?

Please fill out the details below, so we can reach out to you.

Registration Form

Signup to track your record and much more.

We have sent you an email with a registration link. Please click the link to verify your email address, or enter the 6-digit OTP provided in the email.

Didn't receive the OTP. Regenerate OTP Resend