C.H.U.B. - Comment Hyphenation Ugh Bug

Posted March 22nd, 2006 by Mike Cherim

<!--WTF-CHUB--> I recently encountered a bug on one of my sites that has to be the weirdest thing I’ve ever seen. It was a major rendering issue on a single page — the main Showcase page at Accessites.org.

This bug was discovered and reported by Virginia DeBolt, a Macintosh computer OS 10.4 user running the version 2.0 Safari browser. The bug would only manifest itself on that system. Special attention was given to Accessites to ensure it was extremely accessible and cross-browser compatible, so this came as a shock. The result, however was an undeniably unreadable and horrible-looking page.

As you can see in the image floated to the right, The Mac OS10.4 Safari 2.0 render (the background of the image) was all blue, the page background image was peering through the content, and said content was messed up. You can see what it’s supposed to look like in the inset thumbnail. Also shown in this image, the zoomed-in part, you can see the tail of a comment: -->. This was the big clue.

Since this was the only page affected, and the only theme affected didn’t help solve the matter. The markup was the same for all themes, and the site’s Home page had the same content plug-in, the RSS Newsmaker part of the GreenBeast CMS. Very strange. Still that comment tail was visible. Could it be something on that page that made it react to the page’s commenting this way?

I conferred with my friend and master CSS guru, Thierry Koblentz. He couldn’t really point out anything that was the sure-cause of the issue, but he did suggest removing nested hypens within two comments on the page. I was game to try anything. Adding a hyphen within a comment is fine, normally, as long as two consecutive hyphens aren’t used all is hunky-dory. Example:

<!-- adding a single hyphen - like this --> is fine.
<!-- adding a two consecutive hyphens -- like this --> is not.

In this circumstance I had two comments on the page with single hyphen nested within them. I removed them upon Thierry’s suggestion. Amazingly this fixed the problem. The whys and what-fors are still a mystery. The best I can tell, the comment was stopped after the first hyphen in comment one, in the head, then resumed after the second single hyphen in comment two, further down the page (right where the page began display in the screenshot). Why this was happening seems to be a browser bug (and something to do with that page and that page only), but is almost guaranteed to run even deeper than that. It’s fixed now but it doesn’t make sense. The markup, including those hyphenated comments, was the same as the Home page, yet the home page was fine. If you have an issue like this with a page, and you have single hyphens within comments like I did, remove them, test it, and let me know if this fix works for you.

Special thanks goes to Marco Battilana for suggesting I give it a name (new bug fame). The “Ugh” part of it is there for two reasons: To make it speakable, and that demonstrates the frustration part of this little issue.

10 Responses to: “C.H.U.B. - Comment Hyphenation Ugh Bug”

  1. Neal Venditto responds:
    Posted: March 22nd, 2006 at 8:28 pm

    Yes, when commenting you need to be careful. I generally just avoid commenting HTML althogether, but never use hyphens for the reason you mentioned above. Even single hyphens in some older browsers caused issues (Suprised that Safari 2.0 chokes on this, though). But from working with different programming and scripting languages, I’m loathe to use anything but alphanumeric characters, spaces, periods, and commas in comments. If you need fuller puctuation then it probably belongs in a readme or documentation.

  2. Marco Battilana responds:
    Posted: March 23rd, 2006 at 1:06 am

    Hey, thanks for the plug!

    I guess C.H.U.B. is better than calling it ‘Mike’s Hyphen in the Comment’ bug. M.H.I.T.C.B. just doesn’t have the same ring to it ;)

  3. Thomas Tallyce responds:
    Posted: March 24th, 2006 at 9:08 pm

    I think you might find that -- is actually technically the close of a comment, so this is not a bug. I’m not certain; search out the relevant HTML documentation to be sure.


    “A comment starts and ends with “--”, and does not contain any occurrence of “--”.”

    The official spec says:


    “the comment 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.”

  4. James Cram responds:
    Posted: March 25th, 2006 at 2:23 pm

    Strange indeed… I believe Safari’s handling of hyphens in comments was changed in order for it to pass the Acid 2 Test so I guess this bug got introduced then.

  5. Robert Wellock responds:
    Posted: April 21st, 2006 at 5:29 am

    I know I am late to this but is not a bug as such other than probably displaying the dashes. I was surprised you managed to make that mistake of using — inside comments quite a lot of beginners do that for odd reasons. http://www.howtocreate.co.uk/SGMLComments.html

  6. Robert Wellock responds:
    Posted: April 25th, 2006 at 7:21 am

    I must have though you meant nested comments, or consecutive dashes to begin with or one not surrounded by text. As obviously they’d fail well-formedness anyway. Though if they were two separate independent instances containing only one single dash between characters, i.e. then it is a bug assuming other script isn’t triggering it.

Sorry. Comments are closed.

Note: This is the end of the usable page. The image(s) below are preloaded for performance only.