I have a fairly complex page which contains an absolutely positioned table (as the last element in body). The table is created dynamically using jQuery. No matter how I specify the cellspadding attribute, it IE8 in the compatibility mode ignores it. There are several indications as to why it’s being ignored:
-
The layout is off by exactly the default padding (2px).
-
In the IE Developer Tools dock, the property is presented as “cellpadding” (all lowercase) whereas the cellspacing attribute is presented as “cellSpacing”, and if I change its value under the Attributes tab to 0, layout gets fixed and the name is changed to “cellPadding”.
As I said, it’s a fairly complex page (read “messy”) full of ads and content glued from several sources. I plan to do some more investigation, but I was wondering if somebody has encountered the same problem before. It must be some edge case possibly caused an invalid markup resulting in this misinterpretation.
It turned out that the problem was caused by a bug in jQuery (or at least it looks like a bug, unless there are some other reasons I don’t see). I filed it in jQuery bug tracker: #4978. To make the long story short, jQuery handles
cellspacingin a special way and converts it tocellSpacingprior setting its value. It does not do the same thing forcellpadding. This causes a problem for IE7 because the setAtribute() function is by default case-sensitive (in IE7).