March 15, 2008...11:13 pm

IE6 duplicate character bug

Jump to Comments

Do you use a lot of HTML comments in your code? Well it’s very nice habit to keep your code commented, unfortunately IE6 doesn’t like it unless these comments are placed in between floated elements.

Characters will get repeated when there are multiple HTML comments are placed in between floated elements, also called as ghost text bug. First two comments have no effect, but each consecutive comment causes two duplicate characters. Three comments will duplicate three characters, four comments cause four repeating characters & six duplicate characters for five comments. Thanks to Andy Budd for these detailed numbers.

Example code:

<div class=”contentClip”>
<!–Content starts–>
<div class=”content”>
<!–Left column–>
<h1>some text</h1>
<ul>
—–
</div>
<!–Content ends here–>
<!–Footer starts–>

Fix:

Negative 3px right margin to your last float element or make the element 3 px wider again that will cause problems in other version of IE & other browsers, so rather than using hack better to remove or use less comments in floated elements.

Similar article on PositionIsEveryThing.com.


Bookmark and Share

10 Comments


Leave a Reply