ToC ~ Up ~ Prev ~ Next ~ Index Introduction to HTML
Last Update: 20 September 1999

4.11.1 TABLE Element

HTML Tables are contained within a TABLE element. The TABLE element denotes the range of the table, and uses attribute to define properties of it. For example, the BORDER attribute indicates the size of the border to draw around the table and between each of the table's cells -- in the notation of tables, each box within the table is called a cell. There are several other attributes besides BORDER. These are discussed in a later document.

The only two elements allowed inside a table are CAPTION, and TR. CAPTION defines a table caption, and can take one attribute -- ALIGN -- to define where the caption should be placed. Possible values are "top", "bottom" "left" and "right".

TR defines a Table Row -- a table is made up of any number of any number of rows, depending on how you design it. Each row in turn contains cells, denoted either by TD (table data) or TH (table header) elements. The number of TD or TH elements in a given row defines the number of columns in the table, while the number of TR elements defines the number of rows. In general, TD elements are used for data, while TH elements are used for row or column headings. Note that you need to be careful that each row contains the same number of cells -- otherwise the table columns will not line up correctly.

TABLE Example: A Simple Table

Here is a simple table example, -- a table with 3 rows and 4 columns

<TABLE BORDER="1">
 <caption align="bottom">This is the Table Caption</caption>
 <TR> <TH>Heading 1   <TH> Heading 2  <TH> Heading 3    <TH> Heading 4 </TH> </TR>
 <TR> <TD> 0.32 </TD> <TD>  1.2 </TD> <TD> 3.2  </TD>   <TD> alpha  </TD>  </TR>
 <TR> <TD> 0.44 </TD> <TD>  0.3 </TD> <TD> 7.2  </TD>   <TD> beta  </TD>  </TR>
</TABLE>

This table is displayed as:

This is the Table Caption
Heading 1 Heading 2 Heading 3 Heading 4
0.32 1.2 3.2 alpha
0.44 0.3 7.2 beta

Special Things to Note


ToC ~ Up ~ Prev ~ Next ~ Index Introduction to HTML
© 1994-1998 by Ian Graham
Last Update: 20 September 1999