Tables with conflicting columns...

He has: 57 posts

Joined: Dec 2004

Every time I design a webpage I run into the same problem and so I've decided now that I need to ask.

So, here's the deal...

Is it possible to get a table to display correctly when it contains a with 2 columns and ALSO a with 3 columns? Is this possible?

Here's an example:

1 2 3

1 2

The above example just doesn't work out for me.

Is it possible to do this or do I have to separate them into two different tables like I have already been doing? (I'm not a fan of having a bunch of tables on one page.)

Thanks for any feedback, I'm just wondering if I've been missing something this whole time.

Have a great day!

NewTechGuy <----- Heavy emphasis on the "New" part.....lol.....

timjpriebe's picture

He has: 2,667 posts

Joined: Dec 2004

You can have cells span multiple columns. But it looks like to accomodate your example, you would need the following widths: 100px, 50px, 50px, 100px. Then the HTML would look like this.

<table>

<tr>
<td colspan="1" width="100px"></td>
<td colspan="1" width="50px"></td>
<td colspan="1" width="50px"></td>
<td colspan="1" width="100px"></td>
</tr>

<tr>
<td colspan="1" width="100">1</td>
<td colspan="2" width="100">2</td>
<td colspan="1" width="100">3</td>
</tr>

<tr>
<td colspan="2" width="150">1</td>
<td colspan="2" width="150">2</td>
</tr>
</table>
'

Technically, you can leave the colspan="1" out, but it may make it easier to read.

Busy's picture

He has: 6,151 posts

Joined: May 2001

You can only use colspan as Tim mentioned. The golden rule is a table is a box, you can not have a td cell finish within one above or below it, it can span several td's but will always end at the begining or end or the previous td border.

I know what you want, I rememer trying to get it to work for ages when I was learning tables. From your code above, if the top 3 are 100, the bottom ones can only be 100,200 or 200,100

He has: 57 posts

Joined: Dec 2004

Thanks very much for both your responses. I have never looked at tables that way... and now I have a new way to consider.

Thanks again...

Newtechguy

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.