Click to See Complete Forum and Search --> : Fixed column width in HTML tables
Matt James
February 28th, 2003, 02:11 PM
Does anyone know how to fix the width of a <td> object in an HTML table? For example, I have a 5 column table. In the first row is a text string of variable length that spans all five columns. There are 5 more rows underneath that. I want the first 4 columns of the table to be a specific width, while allowing the 5th column to grow as necessary to fill out the row given the length of the row. Does anyone have any ideas (preferably a tag parameter that I'm unaware of)? I'm trying to keep a set of images specifically lined up in the first four columns and keep getting stung when the columns widen up to accomodate long strings in the first row.
Thanks,
Matt
antares686
February 28th, 2003, 03:25 PM
Either use the WIDTH=n paramter or STYLE="WIDTH:nxx" in a row after the varying row in each column to set size or do in all rows.
Ex.
<table border=2 width="100%">
<tr>
<td colspan=5 style="text-align:center">Test</td>
<tr>
<td style="width:5pc">a</td>
<td style="width:5pc"> </td>
<td style="width:5pc"> </td>
<td style="width:5pc">you do have to do for at least one row.</td>
<td<Not tied to a fixed width except due to tables width set.<td>
</tr>
<tr>
<td>a</td>
<td> </td>
<td> </td>
<td> </td>
<td>You don't have to do the width for every row.</td>
</tr>
</table>
I suggest personally using a STYLE and attch to a Cascading Style Sheet to make more flexible and fit into the character of your overall site.
Look at DHTML Objects on MSDN website and you can get more details as to the other length options. 5pc the pc means percent but there are others you can use.
lisrael
March 1st, 2003, 12:22 AM
Nice reply, but I do want to correct one thing. In CSS (cascading style sheets), "pc" means picas (an old typographic unit of measure, little used on the web). To make percent, you use %.
Larry
antares686
March 1st, 2003, 06:24 PM
Thanks, was typing and thinking at the same time. You know how that goes. Also fix typo
<td<Not tied to a fixed width except due to tables width set.<td>
to
<td>Not tied to a fixed width except due to tables width set.<td>
___^
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.