tags:

views:

65

answers:

3

If I have 3 columns for example:

<tr>
      <td></td>
      <td>Know the width</td>
      <td></td>
</tr>

In the 2nd column I know the width, and want this centered for example 777, and want the other 2 sides to take up what is left of the screen (in equal shares), how is this done?

This: simply doesn't work:

  <tr>
        <td width="*%" >&nbsp;</td>
        <td width="777"></td>
        <td width="*%"></td>
  </tr>
+2  A: 

Using floats would work better in this case. You could setup the middle float to have a fixed size, and the other two can be setup to fill the rest (I don't remember the exact css statements)

James Deville
sounds good please explain how?
JL
For tabular data floats wouldn't be a good idea, though :-)
Joey
I don't see how you could do that. How would you tell it to make the left and right floats the same, but unknown, size? Maybe there's a way but I don't know of one.
Jay
+4  A: 

You can use the colgroup element:

<table>
    <colgroup>
        <col width="*">
        <col width="30">
        <col width="*">
    </colgroup>
    <tr>
          <td></td>
          <td>Know the width</td>
          <td></td>
    </tr>
</table>
Joey
ok let me test.........
JL
this doesn't seem to center the middle column on the page..........
JL
ok - lol I see you had a typo :) +1 it works now, and accepted answer
JL
A: 

The following works with css2 browsers. The textaling is needed in the body for IE6.

<html>
    <head>
     <style>
     body{text-align:center;}
     #CenteredDiv{width:400px;margin:auto;background-color:silver;}
     </style>
    </head>
    <body>
     <div id="CenteredDiv">Centered Div</div>
    </body>
</html>

T

Tony Heflin