HTML Table Formatting – Fixed Column Width
Create a table with fixed-width columns regardless of contents.
Notice how a very long entry does not cause a column to expand.
There are three (3) elements involved here to maintain cross-browser consistency.
1) use of width attribute in the table tag
2) use of ‘table-layout:fixed’ property in the style attribute of the table.
3) use of col tags to designate column widths
Make sure the value of the width attribute of the table tag is equal to the total of the width attributes of the col tags.
The 3 elements altogether is redundant if you are using IE. But this approach is needed to take care of the way some browsers like NN behaves differently when specifying column widths.
There are other ways to accomplish this, but this approach is the *easiest* to maintain, especially if you frequently add and delete table rows and/or columns. You don’t have to put style sheet properties on every TD tags.
I used IE6, NN6, Opera7 and Firefox 0.9 to test this. Users of Netscape and Firefox may not like to see table cells with overflowing long texts (because of fixed column-widths), so I updated this FAQ to include the following code in the CSS style definition inside thetags or in the external CSS file: