HTML - <!-- Comments -->
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.- Writing notes or reminders to yourself inside your actual HTML documents.
- Scripting languages such as Javascript require some commenting.
- Temporarily commenting out elements especially if the element has been left unfinished.
HTML Code:
<!--Note to self: This is my banner image! Don't forget -->
<img src="http://www.tizag.com/pics/tizagSugar.jpg" height="100" width="200" />
Comment to self:
- <!-- Opening Comment
- -- > Closing Comment
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.HTML Code:
<!-- <input type="text" size="12" /> -- Input Field -->
HTML Code:
<input type="text" size="12" />
Input Field:
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.HTML Code:
<script>
<!--
document.write("Hello World!")
//-->
</script>
0 comments:
Post a Comment