How to write comments in HTML

Topic: HTML / CSS« Prev|Next »

Answer: Use the Syntax "<!-- text -->"

Comments in HTML are typically used to explain the markup. It will help you and others to select or find the specific section in the document quickly and easily at the time of editing the source code. Comments are not displayed by the browsers.

An HTML comment begins with <!--, and ends with -->. See the example below:

  • <!DOCTYPE html>
  • <html lang="en">
  • <head>
  •     <meta charset="UTF-8">
  •     <title>Comments in HTML</title>
  • </head>
  • <body>  
  •     <!-- This is a single line HTML comment -->
  •     <!-- This is an example of a
  •          HTML multi-line comment  -->
  •     <h1>This is a heading</h1>
  •     <p>This is a paragraph.</p>
  • </body>
  • </html>

Related FAQ

Here are some more FAQ related to this topic:

 
Close

Your Feedback:

 

We would love to hear from you! Please say something.