Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The insertCell() method of the HTMLTableRowElement interface inserts a new cell (<td>) into a table row (<tr>) and returns a reference to the cell.
Note: insertCell() inserts the cell directly into the row. The cell does not need to be appended separately with Node.appendChild() as would be the case if Document.createElement() had been used to create the new <td> element.
You can not use insertCell() to create a new <th> element though.
The cell index of the new cell. If index is -1 or equal to the number of cells, the cell is appended as the last cell in the row. If index is omitted it defaults to -1.
An HTMLTableCellElement that references the new cell.
Thrown if index is greater than the number of cells.
This example uses HTMLTableRowElement.insertCell() to append a new cell to a row.
| HTML # dom-tr-insertcell-dev |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jun 24, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.