Entering Comments in HTML Document

This section describes the HTML comment syntax. Comments can be entered in the content part of any non-metadata elements.

If you want to enter comments into your HTML documents, you should follow these guidelines.

1. A single comment must be coded as "<!-- comment_text -->".

2. Comments can be entered anywhere in the content part of any elements except metadata elements.

3. Comments can not be nested.

4. Tag open and close characters, < and > are allowed are comment text.

Here is a simple example of HTML document that matches the above HTML comment syntax requirements:

<!DOCTYPE html>
<!-- HTML_Comments_Example.html
 - Copyright (c) 2009 HerongYang.com. All Rights Reserved.
-->
<!-- Comment: Start of the document -->
<html>
<head>
<meta charset="iso-8859-1">
<!-- Comment: Metadata elements go here -->
<title>Comments Example</title>
</head>
<body>
<!-- Comment:
   <svg> is a new element introduced in HTML5 -->
Here is an example of SVG graphics:
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
 width="60" height="40" viewBox="0 0 152 102">
<rect width="152" height="102" fill="#000000"/>
</svg>
</body>
</html>
<!-- Comment: End of the document -->

Table of Contents

 About This Book

 Introduction of HTML

 Introduction of HTML5 Features

 HTML Document Structure and Content

HTML Document and Elements Syntax

 HTML Document Syntax

 Document Character Set and Encoding

Entering Comments in HTML Document

 Opening and Closing Tags of Elements

 Using Nested Elements

 Specifying Element Attributes

 Specifying Element Contents

 Element Content Syntax Types

 Using Whitespace Characters

 Using Character Entity References

 Using Numeric Character References

 Displayed and Printed HTML Documents

 Responsive Design of Web Pages

 MathML Integration in HTML Documents

 References

 Full Version in PDF/EPUB