HTML Comments - How to Write


  • HTML comment tag use to insert a comment into a source code. It's good habit to write a comment into a source code to improve user readability and understands.

  • You can also write a specify information inside comments. In this case they will not be display on web document and not visible for the user.

  • A good habit is write comment text inside html pages, scripts and style elements.

  • Comment Tag does not support any Standard Attributes.

HTML Comment Example

An HTML comment begins with "<!--" and ends with "-->".

  <title> HTML Comment Tag </title> 
  <img src="images/jnj.png" width="365" height="86" />  <!-- Image File -->

CSS Comment Example

A CSS comment start with "/*" and ends with "*/" in css file.

/* CSS Style */ 
h4 {
  text-align: center;
  color: purple;       /* Font Color is purple */
  font-family: verdana;

JavaScript Comment Example

Single line comment start with //.

Multi line comment start with /* and end with */.

<script type="text/javascript">
  // start heading h3
  document.write("<h1>This is a heading h3</h1>");

  The fist code is use to h3 heading
  or line break
  document.write("<h1>This is a heading</h1>"+"<br />");