Double Hyphen In Script Makes Firefox Render Strangely
Solution 1:
This is due to Firefox implementing SGML (on which HTML was based) comments strictly. This will only occur when the document is loaded in standards mode (i.e. there is a DOCTYPE).
The first <!
starts a comment. The first --
enters a section in which >
characters are allowed. The second --
(in your script) leaves the section in which >
characters are allowed. The >
at the end of </script>
then ends the comment. The following -->
is therefore no longer part of the the comment and gets rendered as text.
See http://www.howtocreate.co.uk/SGMLComments.html for a comprehensive guide to the issue.
Its also worth noting that the HTML 4 Specification says that 'authors should avoid putting two or more adjacent hyphens inside comments' and the HTML 5 Specification says comments must not 'contain two consecutive U+002D HYPHEN-MINUS characters (--)'.
The solution, as you've found, is to not include --
in the middle of a comment.
Solution 2:
Technically you are not allowed to have double hyphen in a comment in HTML (or XML). So even if browsers "allow" if it is not valid and should fail an HTML validator.
Solution 3:
I can't replicate this. Doesn't show up on 3.0.1.
Post a Comment for "Double Hyphen In Script Makes Firefox Render Strangely"