Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML tag

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

table

Try it »

(More examples are at the bottom of the page)


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support

tag


Tag Definition and Usage Notes

tag.

An HTML table consists of

The tag defines an HTML table
The element defines a table row,, , , and .


Differences between HTML 4.01 and HTML5

In HTML5, only the "border" attribute is supported, and only the values "1" or "" are allowed.


property

elements, one or more ,
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

The tag supports [HTML Global Attributes](/tags/ref-standardattributes.html).

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

The tag supports [HTML Event Attributes](/tags/ref-eventattributes.html).