Firefox & Double-Hyphens in Comments
So in kicking off this blog, before I could even post something about stuff I’m working on, I ran into an interesting problem just setting up the blog itself that I’ll share.
I just freshly installed WordPress 2.9.1 and found a nice clean theme called Clean Home (version 1.2 at the time of install). I’ll probably change it up later, but for now, it’s a nice simple clean slate to start off with. After getting the basic site set up I decided to compare across my typical suite of testing browsers that I always use to verify web pages I’m working on (Safari, FF and Chrome on Mac, and FF, IE, Chrome and Opera on Windows). I was primarily comparing the font rendering to see if I wanted to tweak anything, when I noticed that my non-blog pages (like the About page) had a weird rendering issue only in Firefox (both Mac and Win). Basically, there was a post slug (title, date, author, category, etc.) that was not supposed to be there since they only show up within the blog section of the site. Also, there was a --> displayed at the end of the slug, the telltale sign that an HTML comment tag did not get closed properly. But this code is generated from a template on the server, so it’s exactly the same in all browsers (and works fine in everything BUT Firefox). So what gives?
I examined the page source (found in page.php) and saw this right after the start of the <div class="post"> block:
A big block of HTML — the page title and post slug section — are commented out (but still available to tinkerers like me, which I appreciate). I have never run across the case where having a double-hyphen inside a comment would cause a problem, but being the genius hacker that I am, my first instinct was to remove that and refresh the page — voilà, no more post slug in FF. The block of HTML is now properly commented out.
Out of curiosity I Googled this just to check my sanity, and sure enough, it’s a well-known “bug that’s not a bug” with versions of Firefox going back many years. Basically, the HTML spec (up until version 5) allows whitespace between the -- and the > of a closing comment tag (although interestingly, not in an opening comment tag), and Firefox is apparently the only browser that actually enforces that rule. I found a great write-up on this issue from a blogger who tried unsuccessfully to report this “bug” to Mozilla — if you are a web developer you’ll definitely appreciate it.
Anyway, problem solved and blog officially kicked off, all in one post!
Filed under: Browsers, Web, WordPress | Tags: Firefox, HTML | Comments: Comments Off
Recent Comments