Tuesday, January 30, 2018

HTML - Class 5 - HTML Comments


Comments in HTML
https://weblayoutexpert.blogspot.com/


Assalam-U-Alikum Guys,

Welcome again, Today we learn about Comment in HTML. Basically adding Comments will increase the Readability of our Code or programming. Let suppose you check your code after along period of time, at that you can't properly understand it if you add proper Comments in your source code during coding, that enable understanding about code even after passing many years. 

Now lets Start,

Introduction

The HTML Comment element is basically used to add the comments in an HTML document. Means comment elements make the content as disable code in a Web page, which is not take as part of code. Basically  purpose of Comments is readable explanation or annotation in the HTML code. 

  • The HTML comment elements begin with <!–– and the comment closes with ––>.
  • The HTML comment elements are not displayed in the web browser. 

For example:
------------------------------------------------------------------------------------------------------------------

<p><!-- this tag use for paragraph line --></p>

------------------------------------------------------------------------------------------------------------------


Multi-line Comments

In HTML, using comment elements you can also comments multiple lines text of a HTML page. Comment multiple line text must Begin with <!– tag and End with –> tag and place all text that treat as comment in this tag.

  • HTML comment can span multiple line in you HTML document.
  • Informative text comments when you explain to the code.
For Example:
------------------------------------------------------------------------------------------------------------------

   <body>
      <!--
         <p> This is a multiline comment </p>
         <p>It can span through as many as lines you like</p>
      -->
   </body>


------------------------------------------------------------------------------------------------------------------

Or

------------------------------------------------------------------------------------------------------------------

   <body>

      <h1>Welcome in HTML Tutorial.</h1> <!-- welcome heading that show in web page -->
   
   </body>
------------------------------------------------------------------------------------------------------------------

Conditional Comments

HTML conditional comments are nothing but exactly same like simple comment element in HTML that will be used by only Internet Explorer.
  • Conditional comments only work in IE.
  • Comments between <!–[if IE]> and <![endif]–>.
  • A conditional comment block that is ignored by down-level browsers.

Comment Tag (<comment>)

HTML comment <comment> element is used to insert comment in the source code of HTML. 

  • Comment Tag is supported by only few browsers.
  • It start with <comment> Tag and end with </comment> Tag.

For Example:

   <body>
      <p>IE is <comment>not</comment> supported the HTML comment                   tag.</p>
   </body>


Some more things :
  • If we use JavaScript in our HTML page. then "//" two Slashes in front of Text that need to make Comment.
  • If we are using the CSS in HTML page then "//" for single line Comment and /*...content....*/ is used for multi-line Commenting.


Thank you all for paying attention.

Good Bye (Allah Hafiz)

Tutor : Asad Saleem

No comments:

Post a Comment