<table> / <tr> / <td> / <th>
The <table> element creates a table in HTML. Use <tr> to define rows, <td> for data cells, and <th> for header cells.
Syntax
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
Tags and Attributes
| Tag / Attribute | Description |
|---|---|
| <table> | The container element that wraps the entire table. |
| <tr> | Represents a table row (Table Row). |
| <td> | Represents a table data cell (Table Data). Used for regular content. |
| <th> | Represents a table header cell (Table Header). Text is bold and centered by default. |
| scope | Specifies which cells a <th> header relates to. Accepted values are col (column), row (row), colgroup, and rowgroup. |
Sample Code
<table border="1">
<tr>
<!-- scope="col" marks these as column headers -->
<th scope="col">Name</th>
<th scope="col">Language</th>
<th scope="col">Purpose</th>
</tr>
<tr>
<td>HTML</td>
<td>Markup language</td>
<td>Web page structure</td>
</tr>
<tr>
<td>CSS</td>
<td>Stylesheet language</td>
<td>Web page appearance</td>
</tr>
<tr>
<td>JavaScript</td>
<td>Programming language</td>
<td>Web page behavior</td>
</tr>
</table>
Result
A table with 3 columns and 4 rows is displayed. The first row contains bold headers (Name, Language, Purpose), and rows 2–4 contain the data for each language.
HTML Render Preview
Notes
HTML tables are intended for displaying **tabular data**. In the past, tables were often used for page layout, but today the correct approach is to use CSS Flexbox or Grid. Use tables only for presenting data.
Adding the scope attribute to <th> elements explicitly tells assistive technologies such as screen readers which row or column the header applies to. Use scope="col" for column headers and scope="row" for row headers to improve accessibility.
For elements that give a table more semantic structure — <thead>, <tbody>, <tfoot>, and <caption> — see 'thead / tbody / tfoot / caption'. For merging cells, see 'colspan / rowspan'.
Browser Support
Android Browser
37+ ○
4 or earlier ×
Chrome Android
36+ ○
17 or earlier ×
Firefox Android
79+ ○
3 or earlier ×If you find any errors or copyright issues, please contact us.