I have a problem when I am setting the width for the table and td tags. If I have a width set only for the td tags, and if I am then setting the same width (the sum of the widths for the td tags) for the table tag, then the table size is not the same anymore. It seems like IE is adding some extra space to the td tags in addition to the width that I am setting. Perhaps this example will clarify my problem: <HTML> <HEAD> <title>Problem with Width</title> </HEAD> <body> <table border="1" cellpadding="0" cellspacing="0" style="width:100px;"> <tr><td style="width:100px;">CustomerId</td></tr> <tr><td>412791</td </tr> </table> </body> </HTML> If you view this page in the browser and then remove the style attribute from the table tag and refresh the page, then the size of the table is changed. Is it supposed to be this way and why? I am using IE 6 SP1. Thanks in advance.
Have a look at borderwidth (border-width) for the cells. I think it defaults and even if the border is not displayed, it still renders some space. It shows how to set borderwidth. I think what is happening is that the cell width is a combination of any 'width' you define plus the borderwidth. When you deleted the 100px size, as the text can fit in a smaller space, it renders a smaller space plus the default border width. I tried it with larger values and border-widths in the table and a cell ============= <HTML> <HEAD> <title>Problem with Width</title> </HEAD> <body> <table border="1" cellpadding="0" cellspacing="0" style="border-width: 1cm; "> <tr><td style="border-width: 0cm; ">CustomerId</td></tr> <tr><td>412791</td </tr> </table> --------------------------------- <table border="1" cellpadding="0" cellspacing="0" style="border-width: 1cm; width:200px;"> <tr><td style="border-width: .5cm; width:100px;">CustomerId</td></tr> <tr><td>412791</td </tr> </table> </body> </HTML> ============= I hope this helps http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/properties/border_0.asp