HTML <table>Tag
Examples
A simple HTML table with two columns and two rows:
Try it Yourself »
(See more examples at the bottom of the page)
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the <table> tag.
Tag Definition and Usage Instructions
The <table> tag defines an HTML table.
An HTML table includes a <table> element, one or more<tr>、<th>and<td>elements.
The <tr> element defines a table row, the <th> element defines a table header, and the <td> element defines a table cell.
More complex HTML tables may also include <caption>, <col>, <colgroup>, <thead>, <tfoot>, and <tbody> elements.
Differences Between HTML 4.01 and HTML5
In HTML5, only the 'border' attribute is supported, and only the value '1' or '' is allowed.
Attributes
| Attribute | Value | Description |
|---|---|---|
| align | left center right |
Not supported in HTML5. Deprecated in HTML 4.01.Specifies the alignment of a table relative to the surrounding elements. |
| bgcolor | rgb(x,x,x) #xxxxxx colorname |
Not supported in HTML5. Deprecated in HTML 4.01.Specifies the background color of the table. |
| border | 1 "" |
Not supported in HTML5.Specifies whether the table cells have borders. |
| cellpadding | pixels | Not supported in HTML5.Specifies the white space between the cell edge and its content. |
| cellspacing | pixels | Not supported in HTML5.Specifies the white space between cells. |
| frame | void above below hsides lhs rhs vsides box border |
Not supported in HTML5.Specifies which part of the outside border is visible. |
| rules | none groups rows cols all |
Not supported in HTML5.Specifies which part of the inside border is visible. |
| summary | text | Not supported in HTML5.Specifies a summary of the table. |
| width | pixels % |
Not supported in HTML5.Specifies the width of the table. |
Global Attributes
The <table> tag supportsthe HTML Global Attributes.。
Event Attributes
The <table> tag supportsthe HTML Event Attributes.。
Try it Yourself - Examples
This example demonstrates how to display table headings.
This example demonstrates how to use ' ' to handle cells with no content.
This example demonstrates a table with a caption.
This example demonstrates how to display elements inside other elements.
This example demonstrates how to define table cells that span rows or columns.
Related Articles
HTML Tutorial:HTML Tables
HTML DOM Reference:Table Object
HTML Table Generator:Online HTML Table Generator
Other Extensions