HTML comments code
Comments are used in html to hide some text or code from the browser. Usually comments are used to explain a part of the code to the designer or coder. Some time to break the coding area and to mark different landmark portions, comments are used.
HTML comments are not displayed by the browser. So in any portion of the text or code we don’t want to be displayed or to be ignored by the browser but should stay in the file then we should use comments in html code.
Note that the comments will be available for viewing if we check the view – source code of the page.
If we are using any server side scripting language like PHP then the comments for PHP will not be available to the browser.
Writing comments in any language is a good practice and it makes the code maintenance easy.
Here is the code to generate comments in html
<!-- Line 1this text is commented and not visible -->
The output of above code is here
<br>-Line 2This line will be visible
<br>-<!---Line 3 plus2net , this is also comment --->
<br>-<!--- plus2net --> Line 4 this is not inside comment
-Line 2This line will be visible
Here you can see any > symbol will end the comment and the text after this > symbol will be displayed by the browser.
- Line 4 this is not inside comment
So a comment area starts with <!-- and then ends with --> and does not contain > or – in the body of the commented text or code.
Multi line comments in HTML
Here is the sample code for comments covering more than one line
This is line 1 commented<br>
this is line 2 commented <br>
This is outside the commented area
Be the first to post comment on this article :
|Click for more Questions on HTML|