I’m afraid this cannot be done in HTML, even with the help of CSS. You need some scripting too: a script that processes the table after the browser has formatted it, finds out the widest column, and sets all columns to that width. Assuming your table
element has id=t
, the following pure JavaScript code does the job:
<script>
window.onload = function () {
var tbl = document.getElementById("t");
var row = tbl.rows[0];
var maxWidth = 1;
for ( var i = 0; i < row.childNodes.length; i++ ) {
var width = row.childNodes[i].offsetWidth;
if(width > maxWidth) { maxWidth = width; }
}
for ( var i = 0; i < row.childNodes.length; i++ ) {
row.childNodes[i].style.width = maxWidth + "px";
}
}
</script>