Html comments how to write comment into html

Html comments how to write comment into html

Definition of Comments and Uses
  • Comments are piece of code which is ignored by any web browser. It’s good habit to write a comment into a complex source code to help and improve user readability and understands.
  • HTML Comment lines are indicated by the special tag <!– and ending tag –> placed at the starting and end of every line to be work as a comment.
  • We can also use comment tag for comment but some browsers not support comment tag. <comment> Comment tag by using Comment tag <comment>
  • You can also write a any information inside comments. In this case they will not be display on web browser and not visible for the user and developer can be see and easily understands.
  • A good habit is write comment text inside html pages, scripts, style elements and in any other languages.
  • Comment Tag does not support any Standard Attributes.

Example : HTML Comment.

<html> 
<head>
    <title> Html Comment Examples </title>
</head> 
<body> 
    <!-- Now we are using heading tags and this is html comment--> 
 <h1> Heading h1 </h1> 
  <h2> Heading h2 </h2>
 <h3> Heading h3 </h3> 
  <h4> Heading h4 </h4>
 <h5> Heading h5 </h5> 
  <h6> Heading h6 </h6>
</body> 
</html> 

Output :

Heading h1

Heading h2

Heading h3

Heading h4

Heading h5
Heading h6

Example : CSS Comment.

<html>
<head>
<title> CSS Comment Examples </title>

/* for <p> Tag style */ 
p { 
   text-align:left 
   color:red; /* Font Color is red */
   font-family:verdana;
   font-size:20px; /* Font size is 20 pixels */
   }
   
</head>
<body> 
   <p> Your Paragraph Write Here </p>
</body>
</html>

Example : Java Script Comment.

<html>
<head>
    <title> Java Script Comment Examples </title>
  <script type="text/javascript">
 // Use for Single line comment.
  document.write("<h1>This is a heading h2</h1>");
 /* 
    This is use for multiple line comment. 
 */ 
    document.write("<h1>This is a heading h1 </h1>"); 
   </script> 
</head> 
<body> 
  <h1> Heading h1 </h1>
   <h2> Heading h1 </h2>
</body>
</html>
About Author

My name is Mukesh Jakhar and I am a Web Application Developer and Software Developer, currently living in Jaipur, India. I have a Master of Computer Application in Computer Science from JNU Jaipur University. I loves to write on technology and programming topics. Apart from this, I love to travel and enjoy the beauty of nature.

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.