Correct syntax conditional comment?

A

Andy Dingley

<p><!-- -- --> This is a comment <!-- -- -->!</p>

Is incorrectly interpreted as a paragraph containing "This is a comment!"
by most software claiming to be "browsers".

I think that's simply not interprible in HTML, because it's invalid.

The SGML behaviour for pairs of dashes inside a comment is well
defined (and poorly understood by most), but AFAIR it was deliberately
excluded from the HTML spec. HTML comments just forbid the embedding
of repeated dashes.
 
A

André Gillibert

Andy said:
I think that's simply not interprible in HTML, because it's invalid.

It is valid, no doubt. You can check with the W3C validator or any other
SGML validator.
I think you meant that it isn't conforming.
The SGML behaviour for pairs of dashes inside a comment is well
defined (and poorly understood by most), but AFAIR it was deliberately
excluded from the HTML spec.

The HTML 4.01 specification doesn't say much about comments as it lets
that to the SGML specification.
The few words seem to implicitly assume that there cannot be more than one
comment in a comment declaration.
White space is not permitted between the markup declaration open
delimiter("<!") and *the* comment open delimiter ("--"), but is
permitted between *the* comment close delimiter ("--") and the markup
declaration close delimiter (">").

(Emphasis is mine)
The use of the article *the* rather than *a*, implies (but that's not
explicit) that there cannot be more than one comment in a comment
declaration.
HTML comments just forbid the embedding
of repeated dashes.

Looks like it's true for HTML 4.01.

For HTML 2.0, things were perfectly clear:
To include comments in an HTML document, use a comment declaration. A
comment declaration consists of `<!' followed by zero or more
comments followed by `>'. Each comment starts with `--' and includes
all text up to and including the next occurrence of `--'. In a
comment declaration, white space is allowed after each comment, but
not before the first comment. The entire comment declaration is
ignored.

NOTE - Some historical HTML implementations incorrectly consider
any `>' character to be the termination of a comment.

HTML 3.2 didn't say anything about comments, so I assume that HTML 3.2
used the HTML 2.0/SGML rules.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top