Skip to: content, navigation

by Ian Lloyd

table (HTML element)

Spec
Depr. Empty Version
No No HTML 2
Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full

Example

Here’s a very simple two-column, two-row table:

<table>
  <tr>
    <th>Account Type</th>
    <th>Interest Rate</th>
  </tr>
  <tr>
    <td>Smart</td>
    <td>From 2%</td>
  </tr>
  <tr>
    <td>Young Saver</td>
    <td>From 1.6%</td>
  </tr>
</table>
Type
table element
Contains
caption, col, colgroup, thead, tbody, tfoot, tr
Contained by
block-level elements (except p)

Description

The table element is used to present data in a grid-like fashion (in rows and columns), with appropriate headers to identify the data contained in each column and row.

At its most basic, a table is built using the table, tr, and td elements (with th elements used for marking up the column or row headings), as shown in the example HTML, which renders as shown in Figure 1.

Figure 1. A simple table with no formatting A simple table with no formatting

A more complex table may also include a caption; col and colgroup elements; and the structural thead, tfoot, and tbody elements, which are used to identify the different regions in the table.

Use This For …

A table should only be used for tabular data. It should not be used (or, rather, misused) as a layout mechanism, whether for the layout of an entire web page, or for specific sections of a page. CSS should be used for laying out a page, as it ensures that the content is adaptable to different devices, and doesn’t cause problems when it’s linearized.

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

It causes no compatibility issues, and has excellent support across all tested browsers.

In this Section

User-contributed notes

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters