Beat: Kommentare in HTML

Beitrag lesen

<!-- Dies ist ein Kommentar -->
Ja.

<!--- Dies ist auch ein Kommentar --->
Nicht valide.

<!---- Dies ist auch ein Kommentar ---->
Nicht valide.

<!---[ Dies ist auch ein Kommentar ]--->
Nicht valide.

<!---- Dies -- ist -- auch -- ein -- Kommentar ---->
Nicht valide.

<!-- Dies ist kein Kommentar --->
<!--[ Dies ist kein Kommentar ]--->
<!-------- Dies ist kein Kommentar -->
Richtig.

Aber das hier ist einer: <!------ Dies ist ein Kommentar -->

Stimmt, ich wurde da durch einen Artikel irregeführt.

W3C meint
3.2.4 Comments
<quote>
HTML comments have the following syntax:

<!-- this is a comment -->
<!-- and so is this one,
    which occupies more than one line -->

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.

Information that appears between comments has no special meaning (e.g., character references are not interpreted as such).

Note that comments are markup.
</quote>

und damit ist <!-- dies - ein - Kommentar --   >
Aber die Definition von '--' als Delimitter ist doch nicht explizit.

mfg Beat

--
Selber klauen ist schöner!