HTML DOM Table Object
Table object
The Table object represents the HTML <table> element.
Access Table object
You can use getElementById() to access the <table> element:
var x = document.getElementById("myTable");
Create Table object
You can use the document.createElement() method to create a <table> element:
var x = document.createElement("TABLE");
Table object collection
Collection | Description |
---|---|
cells | Return the collection of all <td> or <th> elements in the table. |
rows | Return the collection of all <tr> elements in the table. |
tBodies | Return the collection of all <tbody> elements in the table. |
Table object properties
Properties | Description |
---|---|
align |
Not supported in HTML5.Please use style.cssFloat. Set or return the alignment of the table relative to the surrounding text. |
background |
Not supported in HTML5.Please use style.background. Set or return the background image of the table. |
bgColor |
Not supported in HTML5.Please use style.backgroundColor. Set or return the background color of the table. |
border |
Deprecated.Please use style.border. Set or return the width of the table border. |
caption | Return the <caption> element of the table. |
cellPadding |
Not supported in HTML5.Please use style.padding. Set or return the space amount between the cell border and the cell content. |
cellSpacing |
Not supported in HTML5.Please use style.borderSpacing. Set or return the amount of space between cells in the table. |
frame |
Not supported in HTML5. Set or return the outer border to be displayed (for the table). |
height |
Not supported in HTML5.Please use style.height. Set or return the height of the table. |
rules |
Not supported in HTML5. Set or return the inner border (between cells) to be displayed in the table. |
summary |
Not supported in HTML5. Set or return a description of the data in the table. |
tFoot | Return a reference to the table's <tfoot> element. |
tHead | Return a reference to the table's <thead> element. |
width |
Not supported in HTML5.Please use style.width. Set or return the width of the table. |
Table object methods
Method | Description |
---|---|
createCaption() | Create an empty <caption> element and add it to the table. |
createTFoot() | Create an empty <tfoot> element and add it to the table. |
createTHead() | Create an empty <thead> element and add it to the table. |
deleteCaption() | Remove the first <caption> element from the table. |
deleteRow() | Delete a row (<tr>) from the table. |
deleteTFoot() | Remove the <tfoot> element from the table. |
deleteTHead() | Remove the <thead> element from the table. |
insertRow() | Create an empty <tr> element and add it to the table. |
Standard properties and events
The Table object supports both standardsPropertiesandEvents.