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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI and Width of Table column

Status
Not open for further replies.

samesale

Programmer
Sep 15, 2003
133
US
I have created the following table.

print &quot;<table width=\&quot;100%\&quot;>\n&quot;;
print &quot;<tr bgcolor=\&quot;red\&quot;><th>Item</th><th>Price</th>\n&quot;;
print &quot;<th>E-Mail</th><th>Telephone</th><th>Time-to-Call</th></tr>\n&quot;;

print &quot;<td align=\&quot;left\&quot; width=\&quot;90\&quot;><font color=\&quot;blue\&quot;> $item</font></td><td align=\&quot;left\&quot; width=\&quot;50\&quot;>$d$price</td>\n&quot;;
print &quot;<td align=\&quot;left\&quot; width=\&quot;50\&quot;><a href=\&quot;mailto: $email\&quot; >$email </a></td><td align=\&quot;left\&quot; width=\&quot;50\&quot;>$phone</td><td align=\&quot;left\&quot; width=\&quot;50\&quot;> $time</td>\n&quot;;
print &quot;<tr align=\&quot;left\&quot; valign=\&quot;top\&quot; bgcolor=\&quot;#FF99FF\&quot;> <td align=\&quot;left\&quot; colspan=\&quot;4\&quot; >$body</td>\n&quot;;
print &quot;<td align=\&quot;left\&quot; colspan=\&quot;1\&quot;><font color=\&quot;blue\&quot;>CODE# I $phone:$count date: $thismon-$mday-$year</font></td></tr></table>\n&quot;;

However, the column size changes. How can I keep them at a fixed length? Please help. Thank.
 
Your table has 5 columns. Since the table is set to width=&quot;100%&quot;, the last column will stretch to fill the width of the browser. To avoid this, set the table width to a number like 600 (not 100%). Also, the widths for your other columns are small, if the data does not fit, the browser may make them wider than requested. You may want to start with a wider value.
 
You shouldn't mix percentages and absolute values when defining tables. Use percentages to define the table AND cell widths OR all absolute values for the same.

There's always a better way. The fun is trying to find it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top