HTML
Example
A simple HTML table with two columns and two rows:
<
table
border
=
"
1
"
<
tr
<
th
Month
th
<
th
Savings
th
tr
<
tr
<
td
January
td
<
td
$100
td
tr
<
tr
<
td
February
td
<
td
$80
td
tr
tableTry it »
(More examples are at the bottom of the page)
Browser support





All major browsers support
Tag Definition and Usage Notes
An HTML table consists of
Differences between HTML 4.01 and HTML5
In HTML5, only the "border" attribute is supported, and only the values "1" or "" are allowed.
property
| and | . |
|---|---|
| elements define the header cells, | elements define the table cells.
More complex HTML tables may also include |
| property | Value | Description |
|---|---|---|
| align | left |
center
right | HTML5 does not support。HTML 4.01 已废弃。 Specifies表格相对周围元素的对齐方式。 |
| 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 a table cell has a border. | | cellpadding | pixels | Not supported in HTML5. Specifies the space between the cell edge and its 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 outer border are visible. | | rules | none
groups
rows
cols
all | Not supported in HTML5. Specifies which parts of the inner border are 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
Event attribute
Try it - Example
Caption in a table
This example demonstrates how to display a table caption.
Empty cells
This example demonstrates how to use " " to handle cells with no content.
A table with a caption
This example demonstrates a table with a caption.
Tags inside a table
This example demonstrates how to display elements inside other elements.
Table cells spanning rows or columns
This example demonstrates how to define table cells that span rows or columns.
Related Articles
HTML Tutorial:HTML Tables
HTML DOM Reference Manual:Table object
HTML Table Generator:Online HTML Table Generator