• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

width of HTML table cell

 
Mike Yu
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have a HTML table, the content of the cells are retrieved from database table. I specified the width of each cell (TD) in my HTML table, but when the cells are filled with content from database, the width of the HTML cells changed in my browser (IE6.0).
The following is an example of my table:
<table width="779">
<tr>
<td width="152">
<!--some code -->
</td>
<td width="621">
<table width="100%">
<tr width="100%">
<!--some code -->
</tr>
<tr width="100%">
<td width="100%">
<table width ="100">
<tr>
<td width="10"> col1</td>
<td width="100"> col2</td>
<td width="74"> col3</td>
<td width="100"> col4</td>
<td width="97">col5 </td>
<%if(condition){%> <td width="159">col6 </td> <%}%>
</tr>
<tr>
<td>value1</td>
<td>value2</td>
<td>value3</td>
<td>value4</td>
<td>value5 </td>
<%if(condition) {%> <td >value6 </td> <%}%>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
The value1 to value6 are retrieved from database. whether col6 and value6 will be displayed or not is conditional.
My problem is that the width of each cell changed based on the length of vaule1 to value6.
Can someone tell me how to make the length of each cell fixed?
 
Randall Twede
Ranch Hand
Posts: 4371
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
assuming you want them the same width as the cells in the previous row, just set them like you did for it.

<table width="779">
<tr>
<td width="152">
<!--some code -->
</td>
<td width="621">
<table width="100%">
<tr width="100%">
<!--some code -->
</tr>
<tr width="100%">
<td width="100%">
<table width ="100">
<tr>
<td width="10"> col1</td>
<td width="100"> col2</td>
<td width="74"> col3</td>
<td width="100"> col4</td>
<td width="97">col5 </td>
<%if(condition){%> <td width="159">col6 </td> <%}%>
</tr>
<tr>
<td width="10">value1</td>
<td width="100">value2</td>
<td width="74">value3</td>
<td width="100">value4</td>
<td width="97">value5 </td>
<%if(condition) {%> <td width="159">value6 </td> <%}%>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic