You can add comments to your XHTML documents to remind yourself, or to document to others what you were trying to do in your Web page. XHTML comments only appear in the page source, and are invisible to users browsing your page - i.e. Web browsers ignore the contents of XHTML comments. An XHTML comment example is shown here:
To add a comment into your XHTML page:
- Go to the location in your XHTML document where you wish to insert a comment. Start the comment by typing "<!--"
- Type your comments.
- When you are finished, type "-->" to close the comment tag.
You can put comments anywhere in an XHTML document, and insert just about anything at all within them.
In summary, XHTML comments can be used anywhere in a Web page to help the author(s) understand the source code - they remain invisible to the web page viewer. Here are some common usages and ticks:
- Comments are particularly useful for describing what you are working on in advanced HTML layouts, or for describing unfinshed work in progress.
- You can use an XHTML comment to temporarily remove an entire section from a page.
- Comments are not invisible to the public, they are simply not rendered by a Web browser. It's very easy for anyone to view the XHTML source and read your comments, so don't write any sensitive information like passwords in a comment field.
- Comments may not have nested comments.
- XHTML comments are a handy way to keep track of different revisions.