Tables (if you were looking for furniture, immediately hit the BACK button on your browser ).
For me, tables are by far the most useful HTML element. As mentioned in the main page, there is little horizontal control of your web page. Only tables and <MULTICOL> give you what little control you have. In many instances, my entire document is one giant table.
<TABLE> <TR> <TD> this is row 1 column 1 </TD> <TD> this is row 1 column 2 </TD> <TD> this is row 1 column 3 </TD> </TR> <TR> <TD> this is row 2 column 1 </TD> <TD> this is row 2 column 2 </TD> <TD> this is row 2 column 3 </TD> </TR> </TABLE>
The effect of the above markup is:
| this is row 1 column 1 | this is row 1 column 2 | this is row 1 column 3 |
| this is row 2 column 1 | this is row 2 column 2 | this is row 2 column 3 |
Just about all tags valid in the <BODY> container are valid within the <TD> (or <TH> container).
Here is the same table with row and column headers.
<TABLE> <TR> <TH>upper left</TH> <TH>col header 1</TH> <TH>col header 2</TH> <TH>col header 3</TH> </TR> <TR> <TH>row header 1</TH> <TD> this is row 1 column 1 </TD> <TD> this is row 1 column 2 </TD> <TD> this is row 1 column 3 </TD> </TR> <TR> <TH>row header 2</TH> <TD> this is row 2 column 1 </TD> <TD> this is row 2 column 2 </TD> <TD> this is row 2 column 3 </TD> </TR> </TABLE>
| upper left | col header 1 | col header 2 | col header 3 |
|---|---|---|---|
| row header 1 | this is row 1 column 1 |
this is row 1 column 2 |
this is row 1 column 3 |
| row header 2 | this is row 2 column 1 |
this is row 2 column 2 |
this is row 2 column 3 |
Still, not very intersting. What is useful are the options that can be used on the various table tags.
Same table with a border of 1
| upper left | col header 1 | col header 2 | col header 3 |
|---|---|---|---|
| row header 1 | this is row 1 column 1 |
this is row 1 column 2 |
this is row 1 column 3 |
| row header 2 | this is row 2 column 1 |
this is row 2 column 2 |
this is row 2 column 3 |
With a border of 5 pixles.
| upper left | col header 1 | col header 2 | col header 3 |
|---|---|---|---|
| row header 1 | this is row 1 column 1 |
this is row 1 column 2 |
this is row 1 column 3 |
| row header 2 | this is row 2 column 1 |
this is row 2 column 2 |
this is row 2 column 3 |
Now 10 pixles.
| upper left | col header 1 | col header 2 | col header 3 |
|---|---|---|---|
| row header 1 | this is row 1 column 1 |
this is row 1 column 2 |
this is row 1 column 3 |
| row header 2 | this is row 2 column 1 |
this is row 2 column 2 |
this is row 2 column 3 |
The border color is picked up from the BGCOLOR= on the <BODY> tag. This will happen whether or not you have a background image on the page.
The width of the table can also be specified. One can specify the number of pixles or a percentage of the viewing window.
Here is a table that is 200 pixles wide. Also, a number has been left off the border statement. The syntax is
| upper left | col header 1 | col header 2 | col header 3 |
|---|---|---|---|
| row header 1 | this is row 1 column 1 |
this is row 1 column 2 |
this is row 1 column 3 |
| row header 2 | this is row 2 column 1 |
this is row 2 column 2 |
this is row 2 column 3 |
Here is a table with the width 100% of the viewing screen.
| upper left | col header 1 | col header 2 | col header 3 |
|---|---|---|---|
| row header 1 | this is row 1 column 1 |
this is row 1 column 2 |
this is row 1 column 3 |
| row header 2 | this is row 2 column 1 |
this is row 2 column 2 |
this is row 2 column 3 |
If you want to center a table, you need to enclose the entire table within the <CENTER> </CENTER> container. The <P align=center> </P> won't work for some browsers.
Here is a table with the default border, 50% of the screen and centered.
| upper left | col header 1 | col header 2 | col header 3 |
|---|---|---|---|
| row header 1 | this is row 1 column 1 |
this is row 1 column 2 |
this is row 1 column 3 |
| row header 2 | this is row 2 column 1 |
this is row 2 column 2 |
this is row 2 column 3 |
Here is the original table:
| upper left | col header 1 | col header 2 | col header 3 |
|---|---|---|---|
| row header 1 | this is row 1 column 1 |
this is row 1 column 2 |
this is row 1 column 3 |
| row header 2 | this is row 2 column 1 |
this is row 2 column 2 |
this is row 2 column 3 |
Here is the table with the default border and a CELLPADDING=10.
| upper left | col header 1 | col header 2 | col header 3 |
|---|---|---|---|
| row header 1 | this is row 1 column 1 |
this is row 1 column 2 |
this is row 1 column 3 |
| row header 2 | this is row 2 column 1 |
this is row 2 column 2 |
this is row 2 column 3 |
Changing the CELLPADDING to 10, our original table looks like:
| upper left | col header 1 | col header 2 | col header 3 |
|---|---|---|---|
| row header 1 | this is row 1 column 1 |
this is row 1 column 2 |
this is row 1 column 3 |
| row header 2 | this is row 2 column 1 |
this is row 2 column 2 |
this is row 2 column 3 |
Here is a table with both the CELLPADDING and CELLSPACING set to zero.
| upper left | col header 1 | col header 2 | col header 3 |
|---|---|---|---|
| row header 1 | this is row 1 column 1 |
this is row 1 column 2 |
this is row 1 column 3 |
| row header 2 | this is row 2 column 1 |
this is row 2 column 2 |
this is row 2 column 3 |
The table tag in the previous example is:
A table tag of;
| upper left | col header 1 | col header 2 | col header 3 |
|---|---|---|---|
| row header 1 | this is row 1 column 1 |
this is row 1 column 2 |
this is row 1 column 3 |
| row header 2 | this is row 2 column 1 |
this is row 2 column 2 |
this is row 2 column 3 |
Setting the border=0 in the above example produces:
| upper left | col header 1 | col header 2 | col header 3 |
|---|---|---|---|
| row header 1 | this is row 1 column 1 |
this is row 1 column 2 |
this is row 1 column 3 |
| row header 2 | this is row 2 column 1 |
this is row 2 column 2 |
this is row 2 column 3 |
Setting the cellpadding=10 (producing some spacing for the text) and the cellspacing=0 produces:
| upper left | col header 1 | col header 2 | col header 3 |
|---|---|---|---|
| row header 1 | this is row 1 column 1 |
this is row 1 column 2 |
this is row 1 column 3 |
| row header 2 | this is row 2 column 1 |
this is row 2 column 2 |
this is row 2 column 3 |
By setting the width to be 100% and changing the bgcolor to silver, one gets a horizontal bar across the page.
| upper left | col header 1 | col header 2 | col header 3 |
|---|---|---|---|
| row header 1 | this is row 1 column 1 |
this is row 1 column 2 |
this is row 1 column 3 |
| row header 2 | this is row 2 column 1 |
this is row 2 column 2 |
this is row 2 column 3 |