Some comments

Line 1

Line 2

in it -->

Line 3

Line 4

Now, in Gecko, select the text in the yellow field, and paste it in the next textarea..

Weird huh? This only happens in standards mode. Check quirksmode.

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.


Indeed, just don't ever use -- in your comments :)

Gecko uses different markup when you select those comments and use 'View Selection Source'. I really don't know which browser renders this correctly (IE, Opera and Gecko all have different output..). I only know this 'markup' sucks big time and is probably "considered harmful" :-).

<Hixie> fwiw the DOM is about as correct as it could be given that markup
<Hixie> so the parser isn't broken
<Hixie> view selection source shows the dom serialisation
<Hixie> and there's no sane way to get a DOM out of that markup, so we do a best-attempt

This is 'that markup':

<!-- -- This is a comment -->
<p>Line 1</p>
<!-- -- another one -->
<p>Line 2</p>
<!-- A comment with <!-- another comment --> in it -->
<p>Line 3</p>
<!-- -- test -->
<p>Line 4</p>
<!-- Lalala --    >
<p>Line 5</p>
<!-- Foo
<p>Line 6</p>
<!-- Foo -- bar >
<p>Line 7</p> -->

This page fired up a bug report and a testcase, made by Boris Zbarsky :-).