Did you find this useful?
Socialize it today.


Adding Comments within your HTML Documents

Tuesday, February 07, 2012

The comment tag is used to insert comments in the source code. Comments are not meant to be displayed in the when the webpage is rendered by the web browser. It is a good practice to use comments to add notes to your HTML code. Doing so can help you when you edit the source code at a later time.

To add a comment in your code, you start the comment you use the following sequence of characters: <!--, and to end the comment you use the following sequence of characters: -->, such as in this <!-- example of a comment. -->

It is also a good idea to use comment to your scripting code. This is to ensure that the code does not display as text for browsers that do not have support for the client side scripting language. Here is an example:

<script type="text/javascript">
<!--
    function popUp() {
        alert("How are you today!")
    }
//-->
</script>

Note: To ensure that browsers do not render comments and handle them appropriately, make sure the comments begin with "<!--", end with "-->" and do not contain "--" or ">" within the comment.

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.



Recommended Books & Training Resources

HTML CSS and JavaScript Editor Creating Web Pages Simplified HTML CSS: The Complete Reference