The TABLE element is used to define displays of data in rows and
Some HTML developers also use nested tables to lay out information on
a Web page.
This latter use of tables may become less necessary
as HTML 4 browsers become available which recognize
The TABLE element was first used as an extension
of HTML for Netscape Navigator browsers.
Formally specified in
1996 in HTML 3.2,
the features of tables were
extended in the HTML 4.0
draft specifications in 1997.
This document summarizes
the HTML 4.0
capabilities for tables.
To make a table, you use several related elements, all contained
within the TABLE element.
Here is a quick list
of the related elements that are typically used together to
create a table:
element to contain
the elements that make
up the table.
An optional CAPTION element to
label the table with
a name or explanation.
One or more
groups of rows.
Each group of rows
consists of an optional
THEAD and TFOOT
and a TBODY
at least one
(table row) elements.
One or more
groups of columns
or COL elements
element at the start
of the table.
of either TH
elements describing nature
of data in cells in row or
TD (table data)
elements to contain data.
Align: the horizontal alignment of the table on the
screen (not the contents of the table).
Possible values are:
left: at the left text margin
center: centered between text margins
right: at the right text margin
the background color
for the cells of the table.
Border: causes browser to render a border around the
table; if missing, the table has no grid around
it or its data.
Cellspacing: space around data cells, in pixels.
Cellpadding: space around data in the cells, in pixels.
the number of columns
in the table.
This is a hint for
the Web browser to
render the table
incrementally as it
receives data, because
the browser "knows" how
many columns there are.
Frame: defines which parts of
table frame to display.
void: No sides. This is the default value.
above: The top side only.
below: The bottom side only.
hsides: The top and bottom sides only.
vsides: The right and left sides only.
lhs: The left-hand side only.
rhs: The right-hand side only.
box: All four sides.
border: All four sides.
where to draw the rules in the table
Rules="(none | groups | rows | cols | all)".
Width: specifies how wide the table will
be; if given as "NN%", the width
is NN% of the width
of the display.
The following attributes have been
identified in RFC1924 and are not yet by supported by many browsers.
a document-wide identifier for
naming positions in the document as distinations
for a hypertext link.
A list of names that may be used by
Lang: the natural (human) language used
by the content of the table.
Title: an annotation of
the TABLE element.
This annotation may
appear, for example,
as a pop up window
in some browsers when
the user passes their
mouse over the table.
Dir: identifies the
layout of rows--such as
column 1 is on the
right (Dir="rtl") or
Used for languages that have different directionality
in reading (not left to right, top to bottom).
Elements Used with TABLE
Contained within a TABLE element, you may put these
CAPTION: used to label a figure or table
Align: position of the caption relative to
figure or table; values include "top" or
TH: identifies a table header cell; and
TD: identifies a table data cell;
Both have Attributes:
Align: horizontal alignment of the paragraphs
in a table row;
"left," "center," "right,"
"justify," and "decimal" (text
aligned on decimal points).
Axes: a comma-separated list of
axis names which correspond to
the row and columns that
pertain to this cell.
Axis: defines an abbreviated
name for a header cell; by
default, the default name is
BGColor: the background
color for the cell.
specifies the alignment character
for use with Align="char";
the offset of the alignment character on
Valign: vertical alignment of material in a cell. Values
include "top," "middle," "bottom," "baseline."
Colspan: the number of columns the cell spans.
Rowspan: the number of rows the cell spans.
Nowrap: prevents the browser from wrapping the
contents of the cell. (depreciated)
TR: identifies a container for a
row of table cells;
BGcolor: background color
COLGROUP: a container for a group of
elements; allows you to set default
properties for these groups of columns.
Id, Class, Lang, and Dir:
same as for TABLE;
Span="n"; the default for
how many columns in this group;
default width for each of the grouped
Align, Char, Charoff, and
VAlign: values for horizontal
and vertical alignment within table
COL: identifies a column;
Span="n": number of columns spanned;
Width="n": width of column
Table data can be lists, images,
and other elements.
TH element is typically rendered as bold text.
TD element is typically rendered as regular weight text.
Always use TR's as "holders" for TH's and TD's.
The browser sets the number of columns in a table to
be the greatest number of columns in all the row.
Blank cells are used to fill any extra columns in the rows.