Is it possible for HTML and/or CSS comments to cause rendering problems?
HTML Comment : <!-- some info -->
CSS : /* some info */
Is it possible for HTML and/or CSS comments to cause rendering problems?
HTML Comment : <!-- some info -->
CSS : /* some info */
I don't recall why, but yes, I've seen that cause a problem in one scenario. In IE, of course. It was an HTML comment.
On rare occasions I have seen some issues with text ghosting in ie6 because of some comments, but other than that I don't believe any comments (css or html) will cause issues, especially in modern browsers.
Not at all, the problem could only occur when you added extra opening or closing letters or even missing sometimes (in which case they are not treated as comments by browser), example:
<!-- some info -->> // extra >
<!- some info --> // missing - from begining
<!-- some info -- // missing >
Same goes true for CSS comments.
The comments you have shown wouldn't cause any display issues but if you do:
<!-- My comment ---------- -->
You can run into problems with Firefox. This is because two dashes signal the end of the comment and the > is the end comment marker. So technically this is valid:
<!-- My -- comment >
So what can happen is that your comments aren't ending where you think they should and so some content remained commented out, or the comment displays on the page.
More detail can be found here:
http://weblog.200ok.com.au/2008/01/dashing-into-trouble-why-html-comments.html
Actually we just ran into such an occasion and I'm still looking for a good explanation.
The problem, in fact, was the notorious IE6 drop float bug (triggered with over-sized content in a fixed width floated div). Before I had a look, the designer was convinced that comments were the problem ("but it works when I remove them!"). And she just might be right; my suspicion is that the HTML comments took extra space, the content became over-sized, and as a result, IE6 choked. Although I still can't find anything solid to back my theory yet:)