(866) 431-6669 (212) 334-3390

Website Development Articles

Comment Tags Can Cause Content Duplication In IE

At ECommerce Partners, we are required to code in XHTML and add relevant comments in between the codes to adhere to good coding practice. So, when the website layout is complex and we want to code the web page in XHTML, then we do have to use floating div's. Sometimes, all this might give rise to weird problems in Internet Explorer (IE) as seen in the following two screenshots:


As you can see in the above examples, the last few words, characters or image gets duplicated and this happens only in IE. So Spooky! What on earth could be the reason?

I wouldn't have guessed it in million years that the reason was the comment tags <!-- comment tag -->. IE can't handle too many comment tags when there are floating div's. As a result, it renders the comment tag in a peculiar way and the result is duplication of content.

The way I found this out was I started coding the HTML from scratch and didn't bother to add comments. I did this to save time and to find out exactly what the problem was. The result was no duplication. I scratched my head as it didn't make sense. So, I removed all comment tags from the original HTML and the result was no duplication.

This has happened to me quite a few times since then and each time, I just deleted all comment tags and it REALLY WORKS!