Why are double hyphens not valid in HTML comments?

HTML standards mode prohibits double hyphens in comments.

<!-- This is a perfectly valid comment - I think. --> <!-- Invalid comment -- definitely. --> 

There are three additional restrictions cited as examples of these invalid examples:

 <!--> invalid --> <!---> invalid --> <!-- invalid ---> 

Why ask all of these cases with small edges? In particular, why is it forbidden to use double hyphens?

+6
source share
1 answer

[Definition: comments can appear anywhere in the document outside of another markup; in addition, they can be displayed in the document type declaration in places permitted by the grammar. They are not part of the character data of the document; An XML processor can, but does not have to, make it possible, an application can receive comment text. For compatibility, the string “-” (double hyphen) should not occur inside a comment.] References to parameter objects should not be recognized inside a comment.

Grammar does not allow comments ending in --->

The XML function seems to be included solely for XML compatibility with SGML http://www.w3.org/TR/REC-xml/#sec-comments

+6
source

Source: https://habr.com/ru/post/977317/


All Articles