HTML and CSS

HTML Comments

Another important piece of markup that you'll want to get started using right away is HTML comments. Comments enable you to hide content or markup for temporary purposes or backward compatibility, to identify sections within your document, and to provide directives for other folks who might be working on the page.

The syntax for an HTML comment looks like this:

<!-- -->

What you are hiding, identifying, or providing in terms of guidance goes between the opening and closing portions of a comment. Example 1-13 hides the text content within the body using comments.

Example 1-13. Hiding text content and markup
<body>
<!--
<p>The content of this paragraph will not appear within the body so long as it's
within a comment.</p>
-->
<p>The content of this paragraph will be displayed, because it's outside of the
comment field.</p>
</body>

You can denote sections within your document, as shown in Example 1-14.

Example 1-14. Hiding text content and markup
<body>

<!-- begin primary content -->


<!--begin footer information-->

</body>

Finally, comments are a useful way to provide directives (see Example 1-15).

Example 1-15. Providing guidance inside a comment
<body>
<!-- Angie: please be sure to use lists instead of tables in this section  -->
</body>