W3cubDocs

/Web APIs

HTMLTableElement: createTBody() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

The createTBody() method of HTMLTableElement objects creates and returns a new <tbody> element associated with a given <table>.

Note: Unlike HTMLTableElement.createTHead() and HTMLTableElement.createTFoot(), createTBody() systematically creates a new <tbody> element, even if the table already contains one or more bodies. If so, the new one is inserted after the existing ones.

Syntax

createTBody()

Parameters

None.

Return value

HTMLTableSectionElement

Examples

let myBody = myTable.createTBody();
// Now this should be true: myBody === myTable.tBodies.item(myTable.tBodies.length - 1)

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
createTBody 20 12 25 15 6 25 25 14 6 1.5 4.4 6

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement/createTBody