Computers & ProgrammingHTML/XHTMLHTML5Web Development

Adding Comments within your HTML Documents

The comment tag is used to insert comments in the source code. Comments are not meant to be displayed 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 comments in your scripting code. This is to ensure that the code does not display as a 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!")

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.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top