Problem with column widths in a table

M

Martin

I trying to generate a table laid out like this:

|----------|-----------------------------------------------|
| | - - - - - Some Text Here - - - - - |
|----------|-----------------------|-----------------------|
| | And Here Too | And Here Three |
|----------|-----------|-----------|-----------|-----------|
| | ABC | DEF | | |
|----------|-----------|-----------|-----------|-----------|
| | | XSW | 123 | |
|----------|-----------|-----------|-----------|-----------|

That is, all of the columns being the same size with
some columns having "headers".

I would like to specify the overall width of the table
to be a percentage and the columns to be a percentage of
the table width.

I'm using:
<TABLE width="80%" cols=5>

And then:
<COLGROUP>
<col width="20%">
<col width="20%">
<col width="20%">
<col width="20%">
<col width="20%">
</COLGROUP>

But, when I try to specify the various colspans,
the width of the columns seems to revert to
some kind of default (with the width depending
on how much data is in the cell).

<tr>
<td>&nbsp;</td>
<td colspan=4>- - - - - Some Text Here - - - - -</td>
</tr>

<tr>
<td>&nbsp;</td>
<td colspan=2>And Here Too</td>
<td colspan=2>And Here Three</td>
</tr>

<tr>
<td>&nbsp;</td>
<td>ABC</td>
<td>DEF</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

Can someone give me a clue as to what I'm doing wrong here?

Thanks.
 
C

Csaba Gabor

My Firefox 1.0.1+ displays your table as expected.
However, IE really munges it up, allocating 50% to
the 1st column and 50% to the remaining columns
(which are grouped by a single colspan).

Shooting from the hip, seems like IE might be off.
If you insert the following ugly html right after the
</COLGROUP>, the situation improves dramatically:

<tr style="display:none"><td>&nbsp;</td><td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

Csaba Gabor from Vienna

Also, during development, <table border> is your friend.
 
M

Martin

Thank you, thank you, thank you !!!

I've been screwing around with this for several hours.

Your fix works perfectly.

BTW, the real table has borders and a bunch of other stuff - I just
left all that out for this example.

Thanks again.
 

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,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top