Read Lesson 8 – HTML Comments Use and Code

Check Lesson 8 – HTML Comments from Learn HTML section on e akhabaar

HTML Comment tags are used to show comments within your source code. These tags are not displayed by a browsers on your computer screen. But however, it is a good practice to include these tags in your source code as they help you and other coders to understand a html code easily.

HTML comment tags are represented by . Therefore, if any text is inserted between these tags , will be marked as comments and will not be displayed by your browser. Example is explained below:







Comment example







Hello, You can find free html tutorial at www.freetutorialpoint.com.







The result will be displayed as:

 

Comment example

Hello, You can find free html tutorial at www.freetutorialpoint.com.

  • Conditional Comments:

Conditional comments are only supported by Internet Explorer 5 onwards, and not by any other browser. These tags are used to pass on conditional instructions to I.E. to do some specific task when a particular criteria is matched.  For example, when you need to execute some additional html tags based on Internet Explorer versions, in such situations you can use conditional comment tags.





 

Conditional Comments Example







   write your conditional instructions here for IE 8



Some paragraph text





  • Comment Tags for Other Browsers:

There are some comment tags, which are supported by other browsers, and not by Internet Explorer e.g. ... Let’s see this example:







Comment Tag Example





You are not using Internet Explorer





Result displayed by Internet Explorer:

 You are using Internet Explorer

Result displayed by other browsers:

 You are not using Internet Explorer

Chapter Summery:

  • Use html tag to add ‘comments’ in your html source code.
  • Use html tag to add ‘comments’ for Internet Explorer only.
  • Use html tag to add ‘comments’ for other browsers.

Interview Questions:

  • Can we add multiple line comments in html comment tags?

Yes, you can add multiple line comments in html comment tag. Place opening tag  before first line and closing tag – -> after last line to add multiple line comments. Let’s learn with below example how to do this:





 

Example







Line one goes here

Line two goes here

Line three goes here

– ->

Write your paragraph text here





The result will be displayed as:

 Write your paragraph text here

  • Can we put one comment tag inside other comment tag?

No, comment tags don’t nest with each other, which means you can’t put one comment inside another comment.

  • What if, we have to add the double dash sequence  “- -” inside the comment. Can we do this in html comment tag?

No, you can’t add double dash sequence inside the comment tag except for closing tag. 

Practice Exercise :





 

Practice Exercise





 First practice question will start from here

First question: HTML stands for ?





In above html code:

  • Put comment tag around text “First practice question will start from here”

Post your comments about Lesson 8 – HTML Comments below.