Advertisement

HTML <table> tag

Examples

A simple HTML table, containing two rows and two columns:

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

Try it yourself

Browser Support

IE Firefox Chrome Safari Opera

All browsers support <table> tag.

Definition and Usage

<Table> tag defines HTML form.

Simple HTML table by the table and one or more elements tr, th, or td elements.

tr element defines a table row, th element defines header, td element defines a table cell.

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

Differences between HTML and XHTML

In HTML 4.01, "align" and "bgcolor" attribute of the table element is not in favor of use.

In XHTML 1.0 Strict DTD, "align" and "bgcolor" attribute of the table element is not supported.

Optional attributes

Attributes value description
align
  • left
  • center
  • right

Deprecated. Use styles instead.

Prescribed form relative alignment of the surrounding elements.

bgcolor
  • rgb (x, x, x)
  • #xxxxxx
  • colorname

Deprecated. Use styles instead.

Prescribed form background color.

border pixels Predetermined width of the table border.
cellpadding
  • pixels
  • %
Provisions blank cells between the edge of its content.
cellspacing
  • pixels
  • %
Provisions blank cells between.
frame
  • void
  • above
  • below
  • hsides
  • lhs
  • rhs
  • vsides
  • box
  • border
Which part of the provisions of the outer border is visible.
rules
  • none
  • groups
  • rows
  • cols
  • all
Which part of the provisions of the medial border is visible.
summary text Summary of the prescribed form.
width
  • %
  • pixels
A predetermined width of the table.

Global Properties

<table> tag supports HTML in the global properties .

Event Properties

<table> tag supports HTML in the event properties .

Examples TIY

form
This example demonstrates how to create a table in an HTML document.
Table Border
This example demonstrates the various types of table borders.
No border table
This case did not demonstrate a table border.
Table headings (Headings)
This example demonstrates how to display table headers.
Empty Cells
This example shows how to use the "& nbsp;" no content processing cell.
Table with headings
This example demonstrates with a title (caption) of the form
Interbank across columns or table cell
This example demonstrates how to define cross or across columns of a table cell.
Tags within the table
This example demonstrates how to display elements in different elements.
Filling the cell (Cell padding)
This example demonstrates how to create a blank cell content and its borders between the use of cell padding.
Cell spacing (Cell spacing)
This example demonstrates how to increase the distance between cells using the cell spacing.
Add a background color or background image to the table
This example demonstrates how to add a background form
Unit Add a background color or background image to the table
This example demonstrates how to add one or more table cell background
Content arranged in a table cell
This example demonstrates how to use the "align" attribute cell contents are arranged in order to create an aesthetically pleasing form.
Frame (frame) property
This example demonstrates how to use the "frame" attribute to control the borders around the table.

Related Pages

HTML DOM Reference Manual: the Table Object