aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes width of HTML table cell Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "width of HTML table cell" Watch "width of HTML table cell" New topic
Author

width of HTML table cell

Mike Yu
Ranch Hand

Joined: Nov 17, 2001
Posts: 175
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?


Thanks,<br />Mike
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

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>


SCJP
Visit my download page
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: width of HTML table cell