HTML Comments

<!--This is a comment which serves as a note to developers and programmers-->

HTML Comment Tag

You can use HTML Comment tag to explain the code to another designer but not to the end user. You can also refer it during editing source code so basically –

  • The comment tag inserts comment inside document code.
  • Comments are invisible to the end users, so this also helps in hiding  a set of codes.
  • Sometimes, you do not want to delete a code but you just want to hide it, then you can use comments.
comment tag

HTML comments syntax

Example of comment tag

<!-- Learn HTML from scratch -->
<h4>Example for comment tag</h4>
<!-- Comments are invisible to end users. -->

<p>Comment tag is used to insert comments inside document code. It is not visible to end users. It is only visible in code area.</p>	

Example of double line comment

    
<p>Example of a double line comment tag.</p>
<!--Learn HTML from scratch. If you learn CSS along with HTML,
  you can enhance the look and feel of your website and if you
  use Bootstrap then you can easily make your website responsive. 
  This is an example of double line comments-->
<p>Use double line comments if your comment does not fit in a line</p>

Comments in Style Sheets

In CSS, on fewer occasions, comments are used to prevent some specific styles. You will understand more about CSS once you learn our CSS tutorial.

/* CSS style properties here */

Sometimes, we require to debug the code to check for some layout errors, then we can comment out the CSS style properties as well to see if the error is due to the style sheet.

Comments in Style Sheets

Example

/*
.csscomment {
  background-color:skyblue;
  border:2px solid violet;}
/*

Interview Questions & Answer

HTML Comments is a comment which serves as a note to developers and programmers. We can also use HTML comments to leave notes and instructions to other developers who may be working on the files in the future.

Comments in HTML 
For example: <!-- HTML Comment -->

Tutorials for all brains!