Bindestriche in Kommentaren
Sebastian Becker
- html
Hallo,
der W3C Validator zeigt mir folgenden "Fehler":
<!-- ----------------------- navigation top table ----------------------- -->
^
Error: invalid comment declaration; check your comment syntax
Darf man in Kommentaren wirklich keine Bindestriche benutzen - und falls ja, gibt es wirklich einen Browser der dann verrückt spielt?
Danke für alle Hinweise,
Grüße,
Sebastian
Hi, Sebastian
Doppelte Bindestriche sind nicht erlaubt. Zitat http://validator.w3.org/docs/errors.html:
<!-- This is the first unterminated comment >
<!-- This is the second one >
The validator (correctly) interprets the `--' in the second comment
as terminating the first comment, and then interprets the text of
the second comment as text between comments, which is not allowed.
Demnach wäre diese Variante korrekt:
<!-- - - - - - navigation top table - - - - - -->
LG Orlando
Hallo,
Hallo,
Darf man in Kommentaren wirklich keine Bindestriche benutzen - und falls ja, gibt es wirklich einen Browser der dann verrückt spielt?
http://www.w3.org/TR/html401/intro/sgmltut.html#h-3.2.4
hier heißt es:
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 (">"). A common error is to include a string of hyphens ("---") within a comment. Authors should avoid putting two or more adjacent hyphens inside comments.
Die meisten Browser sind an dieser Stelle aber fehlerhaft und lassen -- innerhalb eines Kommentars kommentarlos (sorry, aber das Wortspiel mußte sein ;-) durchgehen.
Da sich sowas aber leicht vermeiden läßt (verwende einfach === oder ___ oder ~~~ statt der ---), würde ich keine -- in HTML-Kommentaren verwenden.
Danke für alle Hinweise,
Bitte.
Grüße,
Sebastian
Andreas