I have the following problem:
I have to list several items each with several properties on a web page. The listing is done in two HTML tables. One table for the headers and one table for the items. This separation is needed in order to have possibility to scroll only through the list. (It would be odd to have a scrollbar in the header section). AFAIK there is only one way to do scrolling in a list in HTML is the div overflow property.
The problem is that I need to set the width of columns ( elements) in the whole listing i.e. in header and in the elements list. Here is a simplified example of how it is done now:
<table width="98%">
<tr>
<td>1</td> <td>2</td> <td>3</td> <td>4</td>
</tr>
<div style="width: 100%; height: 300px; overflow-y:scroll">
<table>
<tr>
<td>123456789101112</td> <td>2</td> <td>3</td> <td>4</td>
</tr>
</table>
</div>
</table>
The problem is that since the elements in the list may have long (I mean many characters) values the browsers expand the cells even if width attribute is used. Since the header is in a separate its columns will have a different length then the columns of the div's .
So far I have tried to let the browser render the columns in the list and then get those computed styles and apply them to the header's columns but it seems that the header columns do not get exactly that widths. I have had the same problem in other places in the project, but since there the text widths were the constant I used pixels for the widths, different lengths in FF and in IE8, but now the problem is - I think- even more complex.
How can I make the columns have the same width in both tables?