Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table width in expanding tables.

Status
Not open for further replies.

DavidJA

Programmer
Jan 10, 2002
58
AU
Hey all,

I want to know the 'Best Practice' for coding pages where they need to grow in a certain area.

EG:
A table with 3 columns. Column 2 is to fill the space when the browser window expands. Column 1 and 3 has nested tables in them.

To make the page scale the way I want at higher resolutions, I wouldmake column 1 and 3 a fixed width (in pixels) and make column 2 have a width of 100%.

This appears to work in both IE and NetScrape, but I want to know is this the best way to do it. Not just with 3 columns, but what if I wanted 6 columns, with columns 1,3 and 6 used to take up the space?

Code example as follows:

<table>
<tr>
<td width=&quot;200&quot;>This is where the sub table will go with content in it</td>
<td width=&quot;100%&quot;> </td> <!-- this is the filling space -->
<td width=&quot;200&quot;>This is where the sub table will go with content in it</td>
</tr>
</table>
 
I'm not sure there is such a &quot;correct&quot; way to do it. You should probably use one or the other, pixels or percentages.
I only use percentages for nested table so I leave the outside tables &quot;solid&quot;.
But the way you have it above is probably fine, heck, if it works...


É **new site coming soon**
**don't visit just yet**
 
DavidJA,
As for me, you used the best solution. At least I have used the same for many times and it never fails (if you do it properly).

The idea is simple: for fixed tale cells define width in pixels, the ones that should expand use width=100%.
In case of many colomns their width (as well as height) highly depends on a content you put in. For example, if there's an image it's possible that it will serve as cell width fixer because other cells can &quot;compress&quot; the cell to image width.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top