Results 1 to 4 of 4

Thread: Table dimensions

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    Leicester, UK
    Posts
    123

    Table dimensions

    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]

  2. #2
    New Member
    Join Date
    May 2000
    Posts
    15
    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.

  3. #3
    Junior Member
    Join Date
    May 2000
    Posts
    28
    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.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    Leicester, UK
    Posts
    123
    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!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width