<table>is a container tag used to define a table.
It has a number of attributes of which the commonest are
This defines the width of the border drawn round the table measured in pixels.
This defines the space between the contents of a cell and the cell boundary measured in pixels.
This defines the space between the cells measured in pixels.
This controls the alignment of the table. The value should be left, center or right according to the HTML 3.2 standard. If you wish to centre a table you can enclose it within <center> ... </center> tags.
This useful non-HTML 3.2 attribute controls the colour of the table border using the standard colour notations.
These two non-HTML 3.2 attributes provided more precise control over frame appearance. The normal "3-D" appearance of a table frame is achieved by making the left and top borders lighter in colour and the right and bottom borders darker in colour as if the light source were located to the top and left of the page. These two attriubtes can be used to set the colours used to achieve the effect. Here's an example.
1 | 2 |
3 | 4 |
This non-HTML 3.2 attribute can be used for selective suppression of the lines (or rules) separating cells within a table. There are four possible values.
rows | Only rules between rows are displayed |
cols | Only rules between columns are displayed |
all | All rules are displayed |
none | No rules are displayed |
Here is an example of a table with the internal rules suppressed
New Brunswick | Fredericton |
Nova Scotia | Halifax |
Although the appearance of the rules has been suppressed, the space taken up by them is still used. For the table above the cellspacing attribute is set to 15.
This non-HTML 3.2 attribute provides for selective suppression of the frame round a table. Here's an example.
1 | 2 |
3 | 4 |
The complete set of possible values are above, below, lhs, rhs, hsides, vsides and box. The value indicates the part of the frame that is to be drawn, in the example above frame was set to hsides.
The basic attributes are illustrated with the following examples.
The first example is a "borderless" table. By not using the border attribute no "frame" is drawn. This is often quite useful.
cell 11 | cell 12 |
cell 21 | cell 22 |
cell 31 | cell 32 |
cell 11 | cell 12 |
cell 21 | cell 22 |
cell 31 | cell 32 |
cell 11 | cell 12 |
cell 21 | cell 22 |
cell 31 | cell 32 |
cell 11 | cell 12 |
cell 21 | cell 22 |
cell 31 | cell 32 |
cell 11 | cell 12 |
cell 21 | cell 22 |
cell 31 | cell 32 |
And finally just for IE users, a table with a yellow border. This table is also has the align attribute set to center.
cell 11 | cell 12 |
cell 21 | cell 22 |
cell 31 | cell 32 |