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.

Related Tutorial
Comments in JavaScript
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 -->
<br>-Line 2This line will be visible
<br>-<!---Line 3 plus2net , this is also comment --->
<br>-<!--- plus2net --> Line 4 this is not inside comment
<br>
Hello

The output of above code is here

-Line 2This line will be visible
-
- Line 4 this is not inside comment
Hello

Here you can see any > symbol will end the comment and the text after this > symbol will be displayed by the browser.

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 :


Google+

Post Comment This is for short comments only. Use the forum for more discussions.






OPINION POLL

What is the most important factor of a web site
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2015 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer