DOM Interfaces

HTMLTableElement

Represents a data table and provides access to its sections, caption and live row collection. Use the structure and header semantics of a real table, not table markup for general visual layout. Example result: 1.

Formal Syntax & Structure

html syntaxhtml
const element = document.getElementById('demo'); // HTMLTableElement

Return Value

HTMLTableElement

An existing HTML DOM object associated with the table element in this example; this interface is a type, not a function return contract.

Working Example

Example Snippethtml
<table id="demo">  <caption>Score</caption>  <tbody>    <tr>      <td>5</td>    </tr>  </tbody></table><p>  Result:  <output id="result"></output></p><script>  const e = document.getElementById('demo');  const result = value => { document.getElementById("result").textContent = String(value); };  result(e.rows.length);</script>
HTML Reference