A simple HTML table, containing two columns and two rows:
The <table> tag is supported in all major browsers.
The <table> tag defines an HTML table.
An HTML table consists of the <table> element and 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.
A more complex HTML table may also include <caption>, <col>, <colgroup>, <thead>, <tfoot>, and <tbody> elements.
HTML5 only supports the "border" attribute, and its value can be "1" or "".
| Attribute | Value | Description |
|---|---|---|
| align | left center right |
Not supported in HTML5. Deprecated in HTML 4.01. Specifies the alignment of a table according to surrounding text |
| bgcolor | rgb(x,x,x) #xxxxxx colorname |
Not supported in HTML5. Deprecated in HTML 4.01. Specifies the background color for a table |
| border | 1 "" |
Specifies whether the table cells should have borders or not |
| cellpadding | pixels | Not supported in HTML5. Specifies the space between the cell wall and the cell content |
| cellspacing | pixels | Not supported in HTML5. Specifies the space between cells |
| frame | void above below hsides lhs rhs vsides box border |
Not supported in HTML5. Specifies which parts of the outside borders that should be visible |
| rules | none groups rows cols all |
Not supported in HTML5. Specifies which parts of the inside borders that should be visible |
| summary | text | Not supported in HTML5. Specifies a summary of the content of a table |
| width | pixels % |
Not supported in HTML5. Specifies the width of a table |
The <table> tag also supports the Global Attributes in HTML.
The <table> tag also supports the Event Attributes in HTML.
Table headers
How to create table headers.
Empty cells
How to use " " to handle cells that have no content.
Table with a caption
An HTML table with a caption.
Tags inside a
table
How to display elements inside other elements.
Cells that span more than one row/column
How to define table cells that span more than one row or one column.
HTML tutorial: HTML Tables
HTML DOM reference: Table object
The perfect solution for professionals who need to balance work, family, and career building.
More than 10 000 certificates already issued!
The HTML Certificate documents your knowledge of HTML.
The HTML5 Certificate documents your knowledge of advanced HTML5.
The CSS Certificate documents your knowledge of advanced CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The jQuery Certificate documents your knowledge of jQuery.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
Your message has been sent to W3Schools.