English
German

HTML Comments

HTML Comment

A comment is a way for you as the web page developer to control what lines of code are to be ignored by the web browser.

There are three main reasons you may want your code to be ignored.

  1.      Writing notes or reminders to yourself inside your actual HTML documents.
  2.      Scripting languages such as Javascript require some commenting.
  3.      Temporarily commenting out elements especially if the element has been left unfinished.


Use the last example place text inside your code and documents that the web browser will ignore. This is a great way to place little notes to yourself or to remind yourself what pieces of code are doing what.

Example:

<!-- Comment Here -->

As you can see comment syntax may be a little complicated, there is an opening and a closing much like tags.

  • <!-- Opening Comment
  • -- > Closing Comment

Placing notes and reminders to yourself is a great way to remember your thoughts and to keep track elements embedded in your webpages. Also, your code may exist for many years, these notes to yourself are a great way to remember what was going on as you may not remember 5 or more years down the road.

All combinations of text placed within the comment tags will be ignored by the web browser, this includes any HTML tags, scripting language(s), etc.


HTML Commenting Existing Code

As a web developer often times you may have many works in progress, or elements that aren't quite finished. In this case you may comment out an element until it is 100% ready for the site. Below we have commented out an input form element since we are not quite ready to receive input from our users.

Example:

<!-- <input type="text" size="12" /> -- Input Field -->
 

Now when we are ready to display that element, we can simply remove the comment tags and our browser will readily display the element.


HTML Commenting Scripts

Scripting languages such as Javascript and VBScript must be commented out as well. You will learn that once they are placed within the <script> tags, only then does the browser correctly execute the scripts.

Example:

<script>
<!--
document.write("Hello World!")
//-->
</script>
 

With this example we are jumping far ahead, just be sure you understand when to use comments and where to look for them. They are a very useful tool for any large project.


HTML Tutorial,HTML Comments, HTML Comments example, learn HTML Comments,explain example HTML Comments online free training HTML Tutorial, HTML Tutorial example, learn HTML Comments, online tutorial, download tutorial, HTML Tutorial books, HTML Tutorial videos, live videos HTML Tutorial, learn HTML Tutorial, HTML Tutorial topic HTML Comments, live training HTML Tutorial, download free tutorial