table – table # T
The
table
element
represents a table; that is, data with more than one
dimension.
Permitted contents #
an optional caption element, followed by
zero or more colgroup elements, followed by
an optional thead element, followed by
one tfoot element, followed by
zero or more tbody elements,
or one or more tr elements
or zero or more tbody elements,
or one or more tr elements followed by
an optional tfoot element
Permitted attributes #
-
global attributes
- Any attributes permitted globally.
-
summary = string
#
- A prose description of the structure of the table.
Additional constraints and admonitions #
-
The element table must not appear as a
descendant of the caption element.
-
The align attribute on the table element is obsolete.
Use CSS instead.
-
The width attribute on the table element is obsolete.
Use CSS instead.
-
The bgcolor attribute on the table element is obsolete.
Use CSS instead.
-
The border attribute on the table element is obsolete.
Use CSS instead.
-
The cellpadding attribute on the table element is obsolete.
Use CSS instead.
-
The cellspacing attribute on the table element is obsolete.
Use CSS instead.
-
The frame attribute on the table element is obsolete.
Use CSS instead.
-
The rules attribute on the table element is obsolete.
Use CSS instead.
Permitted parent elements #
any element that can contain
flow elements
Details #
Although in previous versions of HTML a
table
element was only allowed to contain a
tfoot
element if that
tfoot
occurred before any
tbody
or
tr
elements, but not after, the
table
element is now also alternatively allowed to
contain a
tfoot
after any
tbody
or
tr
elements.
DOM interface #
interface HTMLTableElement : HTMLElement {
attribute HTMLTableCaptionElement caption;
HTMLElement createCaption();
void deleteCaption();
attribute HTMLTableSectionElement tHead;
HTMLElement createTHead();
void deleteTHead();
attribute HTMLTableSectionElement tFoot;
HTMLElement createTFoot();
void deleteTFoot();
readonly attribute HTMLCollection tBodies;
HTMLElement createTBody();
readonly attribute HTMLCollection rows;
HTMLElement insertRow(in optional long index);
void deleteRow(in long index);
attribute DOMString summary;
};
Typical default display properties #
table {
display: table;
border-collapse: separate;
border-spacing: 2px;
border-color: gray; }