Tables
Tables are used in HTML pages to present information
in a tabular (formatted) fashion. It also lets HTML authors to design their
pages in an appealing and organised fashion. Before HTML tags for tables
were finalized, authors had to carefully format their tabular information
within <PRE> tags, counting spaces and previewing their output.
Think of your tabular information in light
of the coding explained below. A table has heads where you explain what
the columns/rows include, rows for information, cells for each item. In
the following table, the first column contains the header information,
each row explains HTML table tag, and each cell contains a paired tag
or an explanation of the tag's function.
Table Elements
|
Element |
Description |
<TABLE> ... </TABLE> |
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.
NOTE: Any kind of markup tag can be used in the caption. |
<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. See Table Attributes at the end of
this table for more information. |
Table Attributes |
NOTE:
Attributes defined within <TH> ... </TH>
or <TD> ... </TD> cells override the
default alignment set in a <TR> ... </TR>.
|
Attribute |
Description |
ALIGN (LEFT, CENTER,
RIGHT) |
Horizontal alignment
of a cell. |
VALIGN (TOP, MIDDLE,
BOTTOM) |
Vertical alignment of
a cell. |
COLSPAN=n
|
The number (n)
of columns a cell spans. |
ROWSPAN=n
|
The number (n)
of rows a cell spans. |
NOWRAP |
Turn off word wrapping
within a cell. |
|