how do I do a two column table in css?

They have: 43 posts

Joined: Sep 2005

Hi all,

I'm trying to make a two column table, where the left column stretches with the browser, while the right column always stays at a fixed width. Content will go in the left column, while the right column is for links.

How do I code my css to achieve this? I've got the html part:

<table>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
'

thanks guys

demonhale's picture

He has: 3,278 posts

Joined: May 2005

You can do a whole css two column layout without using tables, visit A List Apart... or search ALA 2 column css in google

They have: 43 posts

Joined: Sep 2005

Cool thanks.

Busy's picture

He has: 6,151 posts

Joined: May 2001

Or you can add CSS to the table

content
navigation

etc, is valid XHTML 1.0 Strict

They have: 27 posts

Joined: Sep 2005

While that does work, it is generally not a good idea to use tables unless absolutely necessary.

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

Try this:

#container {width: 100%;}
#navigation {}
#links {width: 150px;}
'

That's it (I think - haven't worked with tables in a long time). The links column should stay at 150 pixels and the content area will stretch to fill the space. By using external styles you'll be able to add whatever other CSS you want to each of those areas.

<table id="container">
<tr>
<td id="content">
</td>
<td id="links">
</td>
</tr>
</table>
'

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

In case anyone is wondering I just split out all the debate about CSS vs. tables and put it into a new thread. You can find it here:

http://www.webmaster-forums.net/editpost.php?do=editpost&p=192178

DaveyBoy's picture

They have: 453 posts

Joined: Feb 2003

it won't let me view that thread for some reason Sad

DaveyBoy, you do not have permission to access this page. This could be due to one of several reasons:

   1. Your user account may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
   2. If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
'

demonhale's picture

He has: 3,278 posts

Joined: May 2005

hmmm only moderators can argue with the whole thing, why not append it to my old thread css and table combinations...

Renegade's picture

He has: 3,022 posts

Joined: Oct 2002

Seems like Megan linked to the "edit post." Here is the actual thread:
http://www.webmaster-forums.net/showthread.php?t=32919

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.