The syntax for comment declarations in SGML is
comment declaration =
MDO ("<!"), (comment, ( s | comment )* )?, MDC (">")
comment =
COM ("--"), SGML character*, COM ("--")
[10.3 "Comment declaration", Goldfarb p. 390]where the only delimiter recognized in a comment
is COM ("--").
Paraphrasing, a comment declaration is
<!"),
--"),
--"),
--"),
>").
However, since most HTML user agents don't do the right thing, the safest syntax to use is:
<!--")
--",
"<", or
">"
-->").
This generates comments that are legal SGML and will also be correctly processed by all but the most broken browsers.
If you're wondering why the comment syntax is so $!%#*
screwy, it's probably because SGML comments were designed to be
used in markup declarations (e.g., inside <!ELEMENT>
and
<!ATTLIST> declarations in a DTD).
There the syntax makes
perfect sense: comments both start and end with "--".
Comment declarations
(which are what you use in the document instance)
seem to have been added as an afterthought.