HTML <table> Element
The <table> element represents tabular data arranged into rows and columns. It is used when information has meaningful relationships that are easier to understand in a table, such as schedules, price lists, statistics, and comparison data.
Syntax
<table>
<tr>
<th>Heading</th>
<th>Heading</th>
</tr>
<tr>
<td>Data</td>
<td>Data</td>
</tr>
</table>
Attributes
The <table> element supports the global HTML attributes. It does not have any element-specific attributes in modern HTML.
Example
This example creates a simple table with column headings and two rows of data. CSS is used to add borders and spacing rather than obsolete presentational HTML attributes.
Usage Notes
Use the <table> element for information that has a meaningful relationship between rows and columns. Tables should not be used to control the visual layout of a webpage; CSS should be used for page layout instead.
A table can contain elements such as <caption>, <thead>, <tbody>, <tfoot>, <tr>, <th>, and <td> to organize and describe its data.
Accessibility
Use <th> elements to identify row or column headers so assistive technologies can understand the relationship between headings and data cells. A <caption> can also provide a concise description of the table's purpose. For more complex tables, additional header associations may be necessary.
Browser Support
Baseline: Widely available indicates a feature has been supported by core browsers for at least 30 months. At this stage, the feature is considered stable and safe for most websites to use without needing to worry about compatibility issues or fallbacks, as it is supported by the vast majority of users' devices and browser versions.
For detailed browser compatibility information, see Can I Use: HTML <table> Element .
Related Elements
The <table> element works with several elements that define different parts of a table, including <caption>, <thead>, <tbody>, <tfoot>, <tr>, <th>, and <td>.
Specifications
The <table> element is defined in the WHATWG HTML Living Standard .
