MDN self-hosted library · e01.org

HTMLTableElement: createTHead() method

HTML DOM

HTML DOM

The createTHead() method of the HTMLTableElement interface creates a thead element, inserts it before the first element child of the given table that's neither a caption nor a colgroup, or as the last child if no such insertion location is found, and returns it. If the table already has a <thead> element child, this method returns the first such child without creating one.

When creation is needed, this method creates and inserts the element directly, without requiring separate calls to methods such as Document.createElement() and Node.insertBefore().

Syntax

createTHead()

Parameters

None.

Return value

An HTMLTableSectionElement (which is always a thead).

Examples

const myHead = myTable.createTHead();
// Now this should be true: myHead === myTable.tHead

Specifications

Browser compatibility

See also

  • HTMLTableElement.createCaption()
  • HTMLTableElement.createTBody()
  • HTMLTableElement.createTFoot()
  • HTMLTableElement.deleteTHead()