Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > HTML/XHTML

  • Print
  • + Share This
This chapter is from the book

Adding Comments

You can add comments to your (X)HTML documents in order to remind yourself (or future editors) what you were trying to achieve with your (X)HTML tags. These comments only appear when the document is opened with a text editor. They are invisible to visitors in the browser.

Figure 3.21 Figure 3.21 Comments are a great way to add reminders to your text. You can also use them to keep track of revisions.

Figure 3.22 Figure 3.22 Comments are invisible (though they readily appear when the source code is displayed—see page 57).

To add comments to your HTML page:

  1. In your (X)HTML document, where you wish to insert comments, type <!--.

  2. Type the comments.

  3. Type --> to complete the commented text.


  • Comments are particularly useful for describing why you used a particular tag and what effect you were hoping to achieve.

  • Another good use for comments is to remind yourself (or future editors) to include, remove, or update certain sections.

  • You should view your commented page with a browser before publishing to avoid sharing your (possibly) private comments with your public.

  • Beware, however, of comments that are too private. While invisible in the browser, they cheerfully reappear when the user saves the page as (X)HTML code (source). For more information on viewing a page's code, consult The Inspiration of Others on page 57.

  • Comments may not be nested within other comments.

Find extra tips, the source code for examples, and more at

  • + Share This
  • 🔖 Save To Your Account