Help making TABLE widths align?

Discussion in 'HTML' started by Jedi, Dec 1, 2003.

  1. Jedi

    Jedi Guest

    Hi,

    Here's some simple code. If you create an HTML file out of it, you will
    have a better understanding of my question.

    Basically, I have many tables within one main table. Each embedded table
    has a maximum of 5 columns, that may or may not be filled in. I would like
    the columns that aren't filled in to take up the same width as the same
    column in a table in the row below it, thus making each column line up.

    Any ideas?

    Thanks,
    Bodi

    <HTML>
    <BODY
    <P><TABLE cellSpacing=0 cellPadding=0 Border=0 Align=center>

    <TR><TD><TABLE cellSpacing=0 cellPadding=0 Border=1>
    <TD>&nbsp</TD><TD>407</TD><TD>-407</TD><TD>(0)</TD><TD>&nbsp</TD></TR></TABL
    E></TD></TR>

    <TR><TD><TABLE cellSpacing=0 cellPadding=0 Border=1>
    <TD>(35%)</TD><TD>185</TD><TD>-203</TD><TD>(18)</TD><TD>&nbsp</TD></TR></TAB
    LE></TD></TR>

    <TR><TD><TABLE cellSpacing=0 cellPadding=0 Border=1>
    <TD>&nbsp</TD><TD>407</TD><TD>-407</TD><TD>(0)</TD><TD>&nbsp</TD></TR></TABL
    E></TD></TR>

    <TR><TD><TABLE cellSpacing=0 cellPadding=0 Border=1>
    <TD>&nbsp</TD><TD>203</TD><TD>-290</TD><TD>(87</TD><TD>,15%)</TD></TR></TABL
    E></TD></TR>

    </TABLE>
    <BODY>
    </HTML>
    Jedi, Dec 1, 2003
    #1
    1. Advertising

  2. Jedi

    Nico Schuyt Guest

    Jedi wrote:
    > Basically, I have many tables within one main table.


    Probably bad design. Try a div box instead of the main table.

    > Each embedded
    > table has a maximum of 5 columns, that may or may not be filled in.
    > I would like the columns that aren't filled in to take up the same
    > width as the same column in a table in the row below it, thus making
    > each column line up.


    Add a width to the first table cells. Like <td width:"20%">
    Better: use table headings (th) and specify width in CSS
    Nico
    Nico Schuyt, Dec 1, 2003
    #2
    1. Advertising

  3. Jedi

    rf Guest

    "Jedi" <> wrote in message
    news:%Vyyb.108791$...
    > Hi,
    >
    > Here's some simple code. If you create an HTML file out of it, you will
    > have a better understanding of my question.


    Nope. That's your job :)

    > Basically, I have many tables within one main table. Each embedded table
    > has a maximum of 5 columns, that may or may not be filled in. I would

    like
    > the columns that aren't filled in to take up the same width as the same
    > column in a table in the row below it, thus making each column line up.


    Is this tabular data?

    If so:

    Why nest the tables. Exactly the same effect could be obtained with one
    table. You will never get independant tables to line up properly.

    Cheers
    Richard.
    rf, Dec 1, 2003
    #3
  4. Jedi

    Louis Somers Guest

    "Jedi" <> wrote in
    news:%Vyyb.108791$:

    > Hi,
    >
    > Here's some simple code. If you create an HTML file out of it, you
    > will have a better understanding of my question.
    >
    > Basically, I have many tables within one main table. Each embedded
    > table has a maximum of 5 columns, that may or may not be filled in. I
    > would like the columns that aren't filled in to take up the same width
    > as the same column in a table in the row below it, thus making each
    > column line up.

    <snip>


    Why not use one single table like this?:

    <table cellspacing="0" cellpadding="0" border="1" align="center">
    <tr><td>&nbsp;</td><td>407</td><td>-407</td><td>(0)</td><td>&nbsp;</td>
    </tr>
    <tr><td>(35%)</td><td>185</td><td>-203</td><td>(18)</td><td>&nbsp;</td>
    </tr>
    <tr><td>&nbsp;</td><td>407</td><td>-407</td><td>(0)</td><td>&nbsp;</td>
    </tr>
    <tr><td>&nbsp;</td><td>203</td><td>-290</td><td>(87</td><td>,15%)</td>
    </tr>
    </table>

    You could also make absolute widths for your <TD> tags like:

    <td width="20"></td>

    Will make the width 20 pixels regardles if it's empty. Longer text will
    wrap though.


    --
    News Updater, No scripts, No Database
    http://www.xmlssoftware.com/NUpdater
    Louis Somers, Dec 1, 2003
    #4
  5. Jedi

    Isofarro Guest

    Jedi wrote:

    > Basically, I have many tables within one main table.


    Nested tabular data... hmmm interesting.

    > Each embedded table
    > has a maximum of 5 columns, that may or may not be filled in. I would
    > like the columns that aren't filled in to take up the same width as the
    > same column in a table in the row below it, thus making each column line
    > up.
    >
    > Any ideas?


    colgroup and col elements

    --
    Iso.
    FAQs: http://html-faq.com http://alt-html.org http://allmyfaqs.com/
    Recommended Hosting: http://www.affordablehost.com/
    Web Design Tutorial: http://www.sitepoint.com/article/1010
    Isofarro, Dec 1, 2003
    #5
  6. Jedi

    Jedi Guest

    I used nested tables because I thought it would be easier to line up the
    columns. The sample I included is actually part of a much more complex
    page.

    The short of the long is this. I will have 15 rows by 10 columns of data.
    Each "cell" will have a max of 5 (min of 2) pieces of information. I want
    each of those pieces of data to line up in all 15 rows.

    like this:

    1- x y z u (one cell in the 15x10 table)
    2- y z
    3- y z u, r
    4- x y z r

    It could be any combination of that.

    Suggestions?

    Thanks,
    Bodi
    Jedi, Dec 1, 2003
    #6
  7. Jedi

    rf Guest

    "Jedi" <> wrote in message
    news:3wLyb.3541$...
    > I used nested tables because I thought it would be easier to line up the
    > columns. The sample I included is actually part of a much more complex
    > page.
    >
    > The short of the long is this. I will have 15 rows by 10 columns of data.
    > Each "cell" will have a max of 5 (min of 2) pieces of information. I want
    > each of those pieces of data to line up in all 15 rows.
    >
    > like this:
    >
    > 1- x y z u (one cell in the 15x10 table)
    > 2- y z
    > 3- y z u, r
    > 4- x y z r
    >
    > It could be any combination of that.
    >
    > Suggestions?


    Yes, read my earlier post again. Here is the relavent bit, expanded:

    If you have seperate tables (whether they are nested in another one or not)
    you will not be able to make the cells line up. It will not happen. Even if
    you do get them to line up with perhaps cell width simply changing the
    canvas width or the font size will probably muck it up again.

    Put all of the cells in a single table and simply leave the ones that are
    empty just that, empty.

    You could use some CSS to disappear the borders for those empty cells,
    making them "look" as if they were not there.

    Cheers
    Richard.
    rf, Dec 2, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kay
    Replies:
    2
    Views:
    7,136
  2. tshad

    text-align vs align

    tshad, Jun 23, 2005, in forum: HTML
    Replies:
    1
    Views:
    1,242
    David Dorward
    Jun 23, 2005
  3. Paul Lautman

    left align within centre align

    Paul Lautman, Mar 3, 2006, in forum: HTML
    Replies:
    3
    Views:
    563
    Paul Lautman
    Mar 3, 2006
  4. Steve Richter
    Replies:
    1
    Views:
    882
    Mark Rae
    Jun 24, 2007
  5. Daniel Luis dos Santos

    Making JTable column widths obey me

    Daniel Luis dos Santos, Feb 15, 2010, in forum: Java
    Replies:
    2
    Views:
    584
    John B. Matthews
    Feb 16, 2010
Loading...

Share This Page