TABLE - HTML Tables

Appearance: <TABLE> </TABLE>
Attributes: ALIGN=left|center|right, WIDTH=n|p%, BORDER[=n], CELLSPACING=n, CELLPADDING=n
Contents: One CAPTION, TR.
May occur in: BODY, DIV, CENTER, BLOCKQUOTE, FORM, TD, TH, LI, and DD.

Table start with an optional caption followed by one or more rows. Each row consists of one or more cells, which can be either header or data cells. Cells can overlap across rows and columns.

The ALIGN attribute controls the alignment of the table itself, but not of the individual cells. This can be set either in the TR element for an entire row, or in the TD and TH elements for individual cells. The WIDTH attribute can be a pixel width or a percentage. It indicates the suggested width of the table, although the browser can ignore this if it is not possible. A "100%" value means the table will span across the entire browser window.

You can get a border around the table with the BORDER attribute. If you use BORDER without a value, it defaults to a width of one. Otherwise the border is drawn as wide as you specify. You cannot widen or shrink the lines between table cells or rows.

However, you can increase the whitespace inside a table. The CELLSPACING attribute indicates how many pixels there should be between a cell's contents and the border. CELLPADDING indicates how much whitespace (in pixels) there should be between individual cells.

As an example, here is a table from the HTML 3.0 draft:

<TABLE BORDER>
  <CAPTION>A test table with merged cells</CAPTION>
  <TR><TH ROWSPAN=2><TH COLSPAN=2>Average
  <TH ROWSPAN=2>other<BR>category<TH>Misc
  <TR><TH>height<TH>weight
  <TR><TH ALIGN=LEFT>males<TD>1.9<TD>0.003
  <TR><TH ALIGN=LEFT ROWSPAN=2>females<TD>1.7<TD>0.002
</TABLE>

This could appear as follows, in a text browser:

          A test table with merged cells
/--------------------------------------------------\ 
|          |      Average      |  other   |  Misc  |
|          |-------------------| category |--------|
|          |  height |  weight |          |        |
|-----------------------------------------|--------|
| males    |   1.9   |  0.003  |          |        |
|-----------------------------------------|--------|
| females  |   1.7   |  0.002  |          |        |
\--------------------------------------------------/

Notes:


Web Design Group
Reference index ~ Wilbur index ~ Tag overview ~ Feedback

Copyright © 1996 Arnoud "Galactus" Engelfriet.