Tables
Tables
The table is divided into three main parts, a header, a body and a footer. There is also an optional
caption that can be added to the table.
Table is divided into rows each having a number of columns. As with most word processing systems
it is possible to give groups of columns special features and to merge two or more columns together
or two or more rows together.
Element Description:--
defines a table in HTML. If the BORDER attribute is present, your browser displays the table with
a border.
<CAPTION> ... </CAPTION>
defines the caption for the title of the table. The default position of the title is centered at the top of
the table. The attribute ALIGN=BOTTOM can be used to position the caption below the table.
<TR> ... </TR> specifies a table row within a table. You may define default attributes for the
entire row: ALIGN (LEFT, CENTER, RIGHT) and/or VALIGN (TOP, MIDDLE, BOTTOM).
See Table Attributes at the end of this table for more information.
<TH> ... </TH> defines a table header cell. By default the text in this cell is bold and centered.
Table header cells may contain other attributes to determine the characteristics of the cell and/or its
contents. See Table Attributes at the end of this table for more information.
<TD> ... </TD> defines a table data cell. By default the text in this cell is aligned left and centered
vertically. Table data cells may contain other attributes to determine the characteristics of the cell
and/or its contents
Borders These are the lines that surround the table and each cell.
CELLSPACING. The CELLSPACING attribute tells the browser how much space to include
between the walls of the table and between individual cells. (Value is a number in pixels.)
CELLPADDING. The CELLPADDING attribute tells the browser how much space to give data
elements away from the walls of the cell. (Value is a number in pixels
<TABLE>
<!-- start of table definition -->
<TR>
<!-- start of header row definition -->
<TH> first header cell contents </TH>
<TH> last header cell contents </TH>
</TR>
<!-- end of header row definition -->
<TR>
<!-- start of first row definition -->
<TD> first row, first cell contents </TD>
<TD> first row, last cell contents </TD>
</TR>
<!-- end of first row definition -->
<TR>
<!-- start of last row definition -->
<TD> last row, first cell contents </TD>
<TD> last row, last cell contents </TD>
</TR>
<!-- end of last row definition -->
</TABLE>
<!-- end of table definition -->
EXAMPLE OF TABLE
<html><head><title> my food</title></head><body>
<TABLE>
</TABLE></body></html>
Other attributes
ALIGN. The ALIGN attribute is used to determine where the chart will appear relative to the
browser window. Valid values are ALIGN=LEFT and ALIGN=RIGHT. As an added bonus,
text will wrap around the table (if it's narrow enough) when the ALIGN=LEFT or
ALIGN=RIGHT attributes are used.
WIDTH. The WIDTH attribute sets the relative or absolute width of your table in the
browser window. Values can be either percentages, as in WIDTH="50%", or absolute values.
With absolute values, you must also include a suffix that defines the units used, as in px for
pixels or in for inches (e.g., WIDTH="3.5in"). Absolute values for table widths are
discouraged, though.
COLS. The COLS attribute specifies the number of columns in your table, allowing the
browser to draw the table as it downloads.
BORDER. The BORDER attribute defines the width of the border surrounding the table.
Default value is 1 (pixel).
CELLSPACING. The CELLSPACING attribute tells the browser how much space to
include between the walls of the table and between individual cells. (Value is a number in
pixels.)
CELLPADDING. The CELLPADDING attribute tells the browser how much space to give
data elements away from the walls of the cell. (Value is a number in pixels.)