Chapter 2: Understanding HTML


[ Comments ] [ Copyright ] [ Chapter contents ] [ Book contents ]

One last feature of standard HTML deserves a look: the table.

Tabular representation of data is pretty important in most forms of text. For example, the preceeding two pages include three tables; they logically group units of information in a way that is more easily understood (for large aggregates) than an outline or list structure.

Tables are relatively new. NCSA X Mosaic has supported them only since release 2.5 (late 1994), but Netscape 1.0 and 1.1 included full table support. Not all browsers can cope with them (notably the Microsoft web explorer 1.0 browser included with Windows 95).

Tables consist of cells of data, arranged in rows and columns. The cells are automatically resized and realigned to fit the data inserted into them. It is possible to specify that a cell spans two or more columns, or two or more rows; this allows us to create cells containing captions for a block of child cells.

A table is enclosed in the <TABLE> .. </TABLE> tag. Each row in a table is introduced with a <TR> (table row) tag; the </TR> (end of table row) tag is implied by the occurence of either another table row, or the end of a table. Each cell within a row is introduced with a <TD> (table data) tag. (This is implicitly terminated by the next table data, table row, or end of table tag.)

Note that tables don't have any visible border unless you specify that they should have one, using the optional BORDER attribute. For example, <TABLE BORDER="4"> specifies that the table should have a visible four-pixel thick border.

Tables without a visible border are particularly useful if you need to lay out cellular, or columnar, text.

For example:


<TR><TD>Column 1<TD>Column 2<TD>Column 3

<TR><TD>Something here<TD>Something there<TD>Something everywhere


gives rise to:
Column 1 Column 2 Column 3
Something here Something there Something everywhere

The parameters ROWSPAN and COLSPAN make a cell expand to span the specified number of rows or columns. For example:


<TR><TD><TD COLSPAN="2">Horizontal caption

<TR><TD ROWSPAN="2">Vertical caption<TD>A<TD>B



this gives rise to:
Horizontal caption
Vertical captionAB

(The first non-vacant cell spans two columns; the first cell of the second row spans two rows.)

[ Comments ] [ Copyright ] [ Chapter contents ] [ Book contents ]