PDA

Click to See Complete Forum and Search --> : Table dimensions


Michael
Sep 8th, 2000, 06:56 AM
Given the following HTML code:

<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="100">aaa</td>
<td width="100">bbb</td>
</tr>
</table>

Is the overall width of the table 200 or 220? In other words, is cellpadding included in the cell width, or added to it?

Also, where would cellspacing fit into the equation?

Thanks in advance.

Additional: Is the answer the same under both IE and Netscape?

[Edited by Michael on 09-08-2000 at 07:59 AM]

jwilde1
Sep 8th, 2000, 12:27 PM
maybe you could test this by creating an image with a known height and width and then play with the table size properties to look for gaps between the image and the table border. The same test could be done on IE and Ns.

billyo
Sep 9th, 2000, 07:04 PM
In that example, the table would be 200px. Cellspacing is the space between the cells, cell padding is the space between the inner wall of a cell and it's contents. But that's where things can get interesting (or frustrating). If you put a super long single word within a cell within a table that has a specified width and the length of the word exceeds the width of the table, then the table will have to stretch to accommodate that word. So the more cellpadding you have the shorter your text (or images) will need to be to prevent unwanted table distortion. Just for fun, you can exploit this nifty scripting feature of DOM compliant browsers (IE since 1998, NS6 since...):

theTable=document.getElementById("yourTable");
window.status=theTable.offsetHeight + " " + theTable.offsetWidth;

that should show the "actual" width and not the specified width in your status bar.

About NS and IE, it's pretty much over for netscape 4.x it isn't worth pulling hair out over it. But the short answer is, no. Not much of anything is the same under both browsers.

Michael
Sep 10th, 2000, 05:41 AM
Thanks for the info, guys.

Somehow I knew that I wouldn't get a simple one word answer!!!

However, I have something to think about and to play around with.

The reason for my question is that I like to restrict the width of all my pages to 800px, so that I can accomodate the majority of users without them having to use horizontal scroll - which I think is a pain in the a**. Hence I need to calculate fairly accurately any table dimensions.

What about those with 640x480 screens you may ask? Well, in this day and age, its time for them to upgrade!!!