| Tables - sizing |
|
basics expanding < sizing > colors borders alignment nesting navbar quick recap tags epilogue |
You can specify
the exact size of a table, or any of its columns. Normally the cell fits
like a rubber band around its contents. By adding a WIDTH attribute to the
TABLE tag, you set its width to whatever size you want it to be.
<TABLE BORDER="1" WIDTH="200">
You can also specify a percentage of whatever the table is in. On this page 50% will be half the size of the table cell of the right (text) column of this web page. If the table is on its own on a page, it will take half the browser window. Try stretching this page and the page you created in the editor. This one will stay the same, your table will stretch.
<TABLE BORDER="1" WIDTH="50%">
The size of table cells is done the same way, with a WIDTH attribute in the TD tag. The table is 200 wide, the first cell 150, leaving the second cell 50 pixels in width. If you specify the second cell to 50, things will fit precisely. If you set it to a higher value, the table will stretch unpredictably. The table may get wider, the other cells may get smaller. It's always a good idea to specify all sizes, and make sure the numbers add up.
<TABLE BORDER="1" WIDTH="200">
As mentioned earlier, the column size is determined by the cell width. So you only have to specify the cell widths once, in the first row. Again if you specify a different value in another row, the table will behave unpredictably. So if you only specify the widths in the first row, you will save yourself unpleasant surprises.
Always test everything |