Posts in current category

HTML5 <table> tag


May 03, 2021 20:00 HTML5


Table of contents


HTML5 is used to define tables in a document. Please refer to the following 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>
</table>
Try it out . . .
(See bottom of page for more examples)

Browser support

HTML5 <table> tag HTML5 <table> tag HTML5 <table> tag HTML5 <table> tag HTML5 <table> tag

All major browsers support the hashtag.


Label definition and instructions for use

Labels define HTML tables

An HTML table includes one or more elements of the .lt;table>

The element defines the table row, the element defines the header, and the element defines the table unit.

More complex HTML tables may also include elements such as slt;caption>, slt;col;colgroup?gt;,?lt;thead>,?lt;tfoot> and .lt;tbody?gt;


The difference between HTML 4.01 and HTML5

In HTML5, only the "border" property is supported and only the value "1" or "" is allowed.


Property

Property Value Describe
align left
center
right
HTML5 is not supported. H TML 4.01 is obsolete. Specifies the alignment of the table relative to the surrounding elements.
bgcolor rgb(x,x,x)
#xxxxxx
colorname
HTML5 is not supported. H TML 4.01 is obsolete. Specify the background color of the table.
border 1
""
Specify whether the table unit has a border.
cellpadding pixels HTML5 is not supported. Specifies the white space between the edge of the cell and its contents.
cellspacing pixels HTML5 is not supported. Specifies the white space between cells.
frame void
above
below
hsides
lhs
rhs
vsides
box
border
HTML5 is not supported. Specify which part of the outer border is visible.
rules none
groups
rows
cols
all
HTML5 is not supported. Specify which part of the inner border is visible.
summary text HTML5 is not supported. A summary of the prescribed form.
width pixels
%
HTML5 is not supported. Specify the width of the table.


Global properties

The label supports the global properties of HTML.


The event property

The tag supports the event properties of HTML.


HTML5 <table> tag

Try it - instance

The title in the table
This example shows how to display the table title.

Empty cell
This example shows how to use to work with cells without content.

Table with title
This example shows a table with a title.

The label in the table
This example shows how to display elements within other elements.

Table cells that span rows or columns
This example shows how to define table cells that span rows or columns.


Related articles

HTML tutorial: HTML tables

HTML DOM Reference Manual: Table Objects