HTML comment tag is an asset for the programmers as it is the great way to comprehend the code and trouble shoots the coding errors. It is used to pop in the comments within the code. Browser will ignore all the text inside the tag. This tag is invisible for the users.

The HTML Comment tag is consist of an opening and closing tag(<!– –>). These tags can extent across multiple lines of code, which allows you to comment large blocks of HTML code.

Let play with the example here : Copy the following code in to the file and name it example.html and open it using the web browser and see what you get.

You can see the comment in the result has not been displayed, commenting your code is the good practice and is always recommended.

There must not be any space at the start of the comment string as

Multiline Comments:

We have demonstrated how to comment a single line in HTML, now lets have a look what it takes to extent the comment in to multiple line. If your comment extent to multiple lines you can include opening tag() at the end of the last line as demonstrated below.

Conditional Comments:

This type of comments works only for Internet Explorer on windows and hence can be use to give special instruction to explorer on windows.

Here is the example snippet :

All other browsers will take it as normal as the comment starts and ends normally with opening and closing comment tag and will ignore them entirely and only internet explorer 6 will process the instruction given.

You can follow HTML Tags to know more about other available HTML tags that follow HTML 4.01 specifications or to grasp the knowledge about HTML5 Tags your can follow our HTML5 Tags post.

Karun Verma

Karun Verma is a perfectionist and an online marketing expert with keen interest in finding new ideas and innovations in internet. He is the founder of HTMLTUTS+, a blog based on inspiration in Development, Designing and Online Marketing Ideas.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInPinterestGoogle Plus