While hacking on CSS image borders for a new site, I discovered yet another IE6 bug. (I know, you didn't think any more could fit. Haven't we expended our quota already?)
In short: HTML comments mess up IE6 layout for relatively position containers. Yup.
I searched Google to see if other people had problems with IE6 HTML comments, but I didn't find anything specific, so I'm demonstrating it for the good of webdesignerkind.
I was actually trying to understand Position Is Everything's "Four Sided PNG Drop Shadows" layout and extend it for IE6. After all, the December statistics for browser share show that 20% of visitors use it; I figured I'd use a dithered PNG-8 for them.
I built the HTML (substituting my own class names), assigning each div an arbitrary color so I could tell them apart. Then I started commenting pieces out to see how they affected the size of their containing div. With each step, I verified my understanding with Firefox. When I was done, I sent the final page to BrowerShots to see if IE6 had a problem with the layout or just the PNGs. Here's what FireFox had showed me:
Here's what the IE6 screenshot looked like:
I obviously couldn't experiment with BrowserShots, and I couldn't install IE6 because I run Linux. Luckily, my friend Don Chambers came to the rescue. With a IM and a little patience, we discovered that the HTML comments I had left in the page were messing up the display of the relative divs.
Just when you thought it couldn't get any worse: best practices mess up your layout.
I'm obviously not privy to IE6 source code, but looking at it from a programmer's point of view, I'd say that IE6 sets the comments to visibility:hidden to prevent their display, and the relatively positioned divs inherit the setting. But that's just a guess. I verified that removing the comments from the HTML repairs the layout.
If you have IE6 (upgrade if you can), you can see the IE6 comment bug example page and verify it for yourself. Feel free to download the file and abuse it any way you like.
http://www.positioniseverything.net/explorer/dup-characters.html
Either a css style property of display: inline; in the div preceding the comment, or applying this as a style for all floating divs seems to fix the issue. The other option is to use the <!--[if !IE]> syntax which is quite hideous IMO.
The addition of this CSS property actually takes care of a few buggy issues in IE6, so it is recommended to apply this to all floating divs instead of defining it each time before a comment occurs as I did above.
The alternative is to use the following syntax:
which is not very pleasing to the eye IMHO.
[url=http://fileupload.filetac.com/file/8f4a44e1092b3694bbaacc8e79b9d61760b8c01b[/url]
Line 61 contains the green cursor box.
Note that <b>, <i>, <a>, and the rest won't actually work; they'll just be displayed instead of stripped.