Share this Page URL

Chapter 20. Web Page Doodads You Should ... > Sneakily Hiding Text with HTML Comme... - Pg. 236

Web Page Doodads You Should Know About 236 In the lingo of HTML, a comment is a chunk of text that gets completely ignored by the browser. Yes, you read that right: When the browser comes upon a comment, it averts its electronic eyes and pretends that the comment doesn't even exist. What possible use could there be for such a thing? Here are a few: · You can add notes to yourself in specific places of the page. For example, you can add a com- ment such as Here's where I'll put my logo when I've finished it. · You can add explanatory text that describes parts of the page. For example, if you have a table that comprises the header of your page, you can add a comment before the <TABLE> tag such as This is the start of the header. · You can skip problematic sections of your page. If you have a section that isn't working properly, or a link that isn't set up yet, you can convert the text and tags into a comment so as not to cause problems for the browser or the user. · You can add a copyright notice or other info for people who view your HTML source code. To turn any bit of text into a comment, you surround it with the HTML comment tags. Specifically, you precede it with <!-- and follow it with -->, like this: <!--This text is a comment--> To prove that this actually works, here's a simple page that includes a comment (see comment.htm on the CD in this book). <HTML> <HEAD> <TITLE>A Comment Example</TITLE> </HEAD>