JL.
JL.

Reputation: 81342

HTML table layout question

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>

Upvotes: 1

Views: 261

Answers (3)

Tony Heflin
Tony Heflin

Reputation: 71

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

Upvotes: 0

Joey
Joey

Reputation: 354734

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>

Upvotes: 4

Jim Deville
Jim Deville

Reputation: 10672

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)

Upvotes: 2

Related Questions