Table Column Widths, how to set?

liunx

Guest
I am using IE 5.5 and I cannot find a way to set column widths for a table I am working on. Setting the overall width of the table is easy inside the table tag, e.g, <TABLE WIDTH="75%" . . . ><br />
<br />
But using this same width attribute inside a <TH> or <TD> tag to set individual column widths does not seem to work. Any help would be appreciated.<!--content-->you may set the widths inside the TD in either pixels or percentages. You must be careful however: The td will still expand if the content is wider than the allotted space (unless you tell it to hide the overflow).<!--content-->You can force the layout this way:<br />
<br />
<table style="table-layout:fixed" width="75%"><br />
<col width="25%"><br />
<col width="25%"><br />
<col width="25%"><br />
<col width="25%"><br />
<tr> etc<br />
<br />
The table-layout:fixed declaration prvents dynamic resizing of the widths declared in the col tags. Of course it is a good idea to specify how to handle overflow with a style declaration like: td {overflow-y:auto} in the stylesheet.<br />
<br />
And none of this works in defective browsers like Netscrap 4.x<!--content-->How do you tell it to hide the overflow? How compatible is it?<!--content-->Sorry, but putting the WIDTH= parameter does no good no matter what tag I put it inside of. It just doesn't work.<!--content-->Originally posted by Stinger <br />
Sorry, but putting the WIDTH= parameter does no good no matter what tag I put it inside of. It just doesn't work. <br />
it does work... what is the code you are using?<!--content-->Stinger,<br />
<br />
usually I find that by looking at something in the simplest format usually helps to solve a problem. As such, here is an example of a table using widths-tested in ie and netscape4.7<br />
<br />
<br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><br />
<html><br />
<head><br />
<title>Untitled</title><br />
</head><br />
<body><br />
<table width=100% height=200%><br />
<tr><br />
<td width=10% bgcolor=#cccccc>My 10%</td><br />
<td width=25% bgcolor=red>My 25%</td><br />
<td width="*" bgcolor=blue>The rest</td><br />
</tr><br />
</table><br />
<br />
</body><br />
</html><br />
<br />
<br />
If you post your code, we'll help you out.<!--content-->Postilord,<br />
<br />
CobolDino addressed all your questions in his post by showing you the code, and by letting you know that the style declarations are not supported in N4.7, however I cant vouch for the newer netscape 6.x<!--content-->Thanks for all your help. Yes, I finally did get the column widths to work as shown below.<br />
<br />
<TABLE BGCOLOR="ivory" BORDER=6 CELLPADDING=5 CELLSPACING=5 WIDTH=100%><br />
<TR><br />
<TH WIDTH=90%>Item</TH><br />
<TH WIDTH=10%>Quantity</TH><br />
</TR><br />
<TR><br />
<TD WIDTH=90%><INPUT TYPE="checkbox" NAME="Pancake"> Pancakes</TD><br />
<TD WIDTH=10%><INPUT TYPE="text" NAME="Quantity" SIZE="3" MAXLENGTH="2"></TD><br />
</TR><br />
</TABLE><br />
<br />
I am trying to set up an online menu for a restaurant. And like an idiot, I forgot to add the SIZE parameter to the text box, so the browser just kept alloting the default size of whatever to it, which was far more than 3.<!--content-->
 
Back
Top