Forum Moderators: not2easy
<td style="width: 40px;"> ... </td>
Be aware that this will only fix the size of the column if every element in that column would naturally require less space than 40px. Tables and cells will expand to fit the content. Word wrap will work, but if any single word is bigger than the request size, the cell will expand.
<html>
<head>
<title>Untitled</title>
<style type="text/css">
table {
border-collapse: collapse;
border: 1px solid black;
width: 100%;
}
td {
border: 1px solid black;
width: 3.7%;
}
</style>
</head>
<body>
<table id="mytable">
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<script type="text/javascript">
widestCell = 0;
theObj = document.getElementById('mytable').firstChild.firstChild.firstChild;
if(theObj.clientWidth > widestCell) widestCell = theObj.clientWidth;
for(foo=1;foo<27;foo++) {
theObj = theObj.nextSibling;
if(theObj.clientWidth > widestCell) widestCell = theObj.clientWidth;
}document.getElementById('mytable').style.width = (27 * widestCell) + "px";
theObj = document.getElementById('mytable').firstChild.firstChild.firstChild;
theObj.style.width = widestCell + "px";
for(foo=1;foo<27;foo++) {
theObj = theObj.nextSibling;
theObj.style.width = widestCell + "px";
}
document.write("Widest cell: " + widestCell + "px<br>Total width: " + (27 * widestCell) + "px");
</script></body>
</html>
Fill the cells with content and refresh the page...