Comments in HTML

In theory an HTML comment declaration bears the form

<!comments>

where comments represents one or more comments each wrapped in a pair of -- characters. Thus the following are all legal comments

In practice prudence dictates that an HTML comment be considered to bear the form

<!--comment text-->

- which in any case is what most developers believe! It is best not to use the - and > characters inside comments. As is so often the case, we have to make an exception to this rule in order to allow for the vagaries of IE. Conditional comments, discussed next, require the use of a > character inside the comment.

Jump To...

Colophon