html tutorial - HTML – Comments - html5 - html code - html form



  • The comment tag is used to insert the comments in source code. The browsers are not displaying the comments.
  • To explain the code we can use comments tag.
  • If we have a lot of coding lines the comment tag is used.

Syntax for comments in HTML

<!--comments-->

Sample coding for comment tag:

<!DOCTYPE html>
  <html >
    <body>
       <!--This is the comment tag--> 
       <h1>This is a heading tags to display a header</h1> 
       <!--Comments are not displayed in the browser-->
    </body>
  </html>

Code Explanation for comment tag:

code-explanation for comments

  1. The comment is highlighted and it is hidden. The comment tag is not displayed in the Browser.
Yes Yes Yes Yes Yes

Tips and notes:

  • If you hide the scripts from browsers without support for scripts using the comment tag.
  • The comment tag is used for large code program.
  • Now the JavaScript is also executing the -->tag. In previous, using two forward slashes (//) at the end of the comment line.