Latest web development tutorials

HTML <table> tag

Examples

A simple HTML table, containing two two lines:

<table border="1">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>

try it"
(For more examples, see the bottom of the page)

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the <table> tag.


Tag definitions and instructions

<Table> tag defines an HTML table

The table includes a HTML <table> element, one or more <TR> , <TH> and <td> elements.

<Tr> element defines a table row, <th> element defines the table header, <td> element defines a table cell.

More complex forms may also include HTML <caption>, <col>, <colgroup>, <thead>, <tfoot> and <tbody> element.


Differences between HTML 4.01 and HTML5

In HTML5 support only "border" property, and only allow the use of the value "1" or "."


Attributes

属性 描述
align left
center
right
HTML5 不支持。HTML 4.01 已废弃。 规定表格相对周围元素的对齐方式。
bgcolor rgb(x,x,x)
#xxxxxx
colorname
HTML5 不支持。HTML 4.01 已废弃。 规定表格的背景颜色。
border 1
""
规定表格单元是否拥有边框。
cellpadding pixels HTML5 不支持。规定单元边沿与其内容之间的空白。
cellspacing pixels HTML5 不支持。规定单元格之间的空白。
frame void
above
below
hsides
lhs
rhs
vsides
box
border
HTML5 不支持。规定外侧边框的哪个部分是可见的。
rules none
groups
rows
cols
all
HTML5 不支持。规定内侧边框的哪个部分是可见的。
summary text HTML5 不支持。规定表格的摘要。
width pixels
%
HTML5 不支持。规定表格的宽度。


Global Properties

<table> tag supports HTML global properties .


Event Properties

<table> tag supports HTML event properties .


Examples

Try - Example

Table title
This example demonstrates how to display table headers.

Empty Cells
This example demonstrates how to use the "& nbsp;" no content processing cell.

Table with headings
This example demonstrates with a title (caption) form.

Tags within the table
This example demonstrates how to display elements inside other elements.

Interbank across columns or table cell
This example demonstrates how to define cross or across columns of a table cell.


related articles

HTML Tutorial: HTML table

HTML DOM Reference Manual: the Table Object