
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM TableHeader Object
The HTML DOM TableHeader Object represent the <th> element of an HTML document.
Create TableHeader object
Syntax
Following is the syntax −
document.createElement(“TH”);
Properties of TableHeader object
Property | Explanation |
---|---|
cellIndex | It returns the position of a cell in the cell collection of a table row. |
colSpan | It returns and alter the value of colspan attribute of a table. |
headers | It returns and alter the value of headers attribute of a table. |
abbr | It returns and alter the value of abbr attribute of a table. |
rowSpan | It returns and alter the value of rowspan attribute of a table |
Let us see an example of TableHeader object:
Example
<!DOCTYPE html> <html> <style> body { color: #000; background: lightblue; height: 100vh; text-align: center; } table { margin: 2rem auto; width: 400px; } .btn { background: #db133a; border: none; height: 2rem; border-radius: 2px; width: 40%; display: block; color: #fff; outline: none; cursor: pointer; margin: 1rem auto; } </style> <body> <h1>DOM TableHeader Object Demo</h1> <table border="2"> <thead> <tr class="table-header"> </tr> <thead> <tbody> <tr> <td>John</td> <td>English</td> </tr> <tr> <td>Elon</td> <td>Germany</td> </tr> </tbody> </table> <button onclick="get()" class="btn">Create a TableHeader</button> <script> function get() { var th1 = document.createElement("TH"); var th2 = document.createElement("TH"); th1.innerHTML = "Name"; th2.innerHTML = "Language"; document.querySelector('.table-header').appendChild(th1); document.querySelector('.table-header').appendChild(th2); } </script> </body> </html>
Output
Click on “Create a TableHeader” button to create a TableHeader object.
- Related Articles
- HTML DOM TableHeader abbr Property
- HTML DOM HTML Object
- HTML DOM Object Object
- HTML DOM Ins Object
- HTML DOM HR Object
- HTML DOM Variable Object
- HTML DOM aside Object
- HTML DOM Abbreviation Object
- HTML DOM Address Object
- HTML DOM Meter Object
- HTML DOM MouseEvent Object
- HTML DOM Nav Object
- HTML DOM Ol Object
- HTML DOM Time Object
- HTML DOM Title Object

Advertisements