/

HTML / CSS / JavaScript Tutorial

HTML Element: <table>

[this page | pdf | back links]

The HTML <table> element indicates a table. It typically includes one or more <tr> elements and, within them, <td> and/or <th> elements. More complicated table layouts can also include <caption>, <col>, <colgroup>, <tbody>, <tfoot> and <thead> elements.

 

The attributes it can take are HTML global attributes and HTML event attributes.

 

It used to support the align, bgcolor, border, cellpadding, cellspacing, frame, rules, summary and width attributes, but these are no longer supported by HTML 5. Original draft versions of HTML 5 also included a sortable attribute, but this appears to have been dropped in later specifications and not to have been implemented so far by major browsers.

 

To create or access such an element in JavaScript see here. The corresponding HTML DOM object supports standard DOM properties and methods. It also supports the following additional properties and methods:

 

Additional properties:

 

Property

Description

More

caption

Returns the <caption> element of the table

Here

rows

Returns a collection of the <tr> elements of the table

Here

tBodies

Returns a collection of <tbody> elements of the table

Here

tFoot

Returns the <tfoot> element of the table

Here

tHead

Returns the <thead> element of the table

Here

 

Additional methods:

 

Method

Description

More

createCaption()

Creates empty <caption> element and adds to table

Here

createTFoot()

Creates empty <tfoot> element and adds to table

Here

createTHead()

Creates empty <thead> element and adds to table

Here

deleteCaption()

Removes first <caption> element from table

Here

deleteRow()

Removes a <tr> element from table

Here

deleteTFoot()

Removes first <tfoot> element from table

Here

deleteTHead()

Removes <thead> element from table

Here

insertRow()

Creates empty <tr> element and adds to table

Here

 

The default style applicable to this element is shown here.

 


NAVIGATION LINKS
Contents | Prev | Next | HTML Elements


Desktop view | Switch to Mobile