Description

The <table> tag is used to represents data in a grid-like fashion (in rows and columns).

The following table summarizes the usages context and the version history of this tag.

Placement:Block
Content:An optional <caption>, zero or more <col> or <table> tags, optional <thead> and <tfoot>, zero or more <tbody> tags and at least one <tr>
Start/ End Tag:Start tag: required, End tag: required
Version:HTML 3.2, 4, 4.01, 5

Usage Notes

  • Tables are used to organize data like, text, images, links, forms, form fields, other tables, etc. into rows and columns of cells.
  • At its most basic, a table is built using the <table> element and one or more, <tr>, <th> and <td> elements. Where the <tr> element defines a table row, the <th> element defines a table header, and the <td> element defines a table cell.
  • A more complex table may also include a <caption>, <col> and <table> elements; and the structural <thead>, <tbody>, and <tfoot> elements, which are used to identify the different regions in the table.

Syntax

The basic syntax of the <table> tag is given with:

HTML/XHTML: <table> ... </table>

The example below shows the <table> tag in action.

<table>
    <caption>User Details</caption>
    <thead>
        <tr>
            <th>No.</th>
            <th>Name</th>
            <th>Email</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>John Carter</td>
            <td>johncarter@mail.com</td>
        </tr>
        <tr>
            <td>2</td>
            <td>Peter Parker</td>
            <td>peterparker@mail.com</td>
        </tr>
        <tr>
            <td>3</td>
            <td>John Rambo</td>
            <td>johnrambo@mail.com</td>
        </tr>
    </tbody>
</table>    

Tip: Consider describing the structure of the table in a <caption>> element or, simplify the structure of the table so that no description is needed.

Tag-Specific Attributes

The following table shows the attributes that are specific to the <table> tag.

Global Attributes

Like all other HTML tags, the <table> tag supports the global attributes in HTML5.

Event Attributes

The <table> tag also supports the event attributes in HTML5.

Browser Compatibility

Element
<table>YesYesYesYesYes