Help making TABLE widths align?

J

Jedi

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>
 
N

Nico Schuyt

Jedi said:
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
 
R

rf

Jedi said:
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.
 
L

Louis Somers

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.
 
I

Isofarro

Jedi said:
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
 
J

Jedi

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
 
R

rf

Jedi said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top