table element | table object
[This documentation is preliminary and is subject to change.]
Specifies that the contained content is organized into a table with rows and columns.
![]() ![]() |
Standards information
- Document Object Model (DOM) Level 2 HTML Specification, Section 1.6.5
- HTML 4.01 Specification, Section 11.2.1
HTML information
| Closing Tag | required |
|---|---|
| CSS Display | block |
DOM Information
Inheritance Hierarchy
Remarks
The following tags are valid in table construction: CAPTION, COL, COLGROUP, TBODY, TD, TFOOT, TH, THEAD, and TR.
For each table object, only one tHead and tFoot can be specified.
While a document loads, modifications to a table are restricted until the onload event occurs. Read-only access is allowed at any time.
The table object model is read-only for databound tables. For example, script used to remove a table row works correctly on an unbound table, but not on a databound table. The properties of a table object are still available, but changes to the bound data in a table must be made to the data source.
The properties of a table are distinct from the properties of cells contained within the table. For example, the offsetLeft property of a multicolumn table is not the same as the offsetLeft property of the left-most cell in the table. Refer to the appropriate object when writing scripts involving table objects, cell objects, or both.
The table object and its associated elements have a separate table object model, which uses different methods than the general object model. For more information on the table object model, see Building Tables Dynamically.
When scripting the height property, use either the pixelHeight or posHeight property to numerically manipulate the height value.
If dynamic changes are intended for the height and width, the original values should be set through style (for example, style="height:200px; width:200px") rather than through the height and width attributes.
Many styles do not inherit to a table and its
contents from its parent object. Among these are: font-size; font-weight; line-height; text-align; font-style; font-variant.
Windows Internet Explorer 8 will only render tables up to 1000 columns. To force Windows Internet Explorer 7 rendering mode, see How Do I Take Advantage of the New Features in Internet Explorer 8.
Examples
This example uses the TABLE element with THEAD, TR, and TH to create a table with three rows and two columns.
<TABLE BORDER=1 WIDTH=80%> <THEAD> <TR> <TH>Heading 1</TH> <TH>Heading 2</TH> </TR> </THEAD> <TBODY> <TR> <TD>Row 1, Column 1 text.</TD> <TD>Row 1, Column 2 text.</TD> </TR> <TR> <TD>Row 2, Column 1 text.</TD> <TD>Row 2, Column 2 text.</TD> </TR> </TBODY> </TABLE>
See also
Build date: 3/8/2012

