HTML Tables
HTML Tables
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
HTML Tables
❮ Previous Next ❯
HTML tables allow web developers to arrange data into rows and columns.
Example
Try it Yourself »
Example
https://www.w3schools.com/html/html_tables.asp 1/8
13/07/2025, 18:33 HTML Tables
<table>
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>
Try it Yourself »
Table Cells
Each table cell is defined by a <td> and a </td> tag.
Example
<table>
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
https://www.w3schools.com/html/html_tables.asp 2/8
13/07/2025, 18:33 HTML Tables
</tr>
</table>
Tutorials Exercises Services Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
Try it Yourself »
Note: A table cell can contain all sorts of HTML elements: text, images, lists, links,
other tables, etc.
Table Rows
Each table row starts with a <tr> and ends with a </tr> tag.
Example
<table>
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
<tr>
<td>16</td>
<td>14</td>
<td>10</td>
</tr>
</table>
Try it Yourself »
https://www.w3schools.com/html/html_tables.asp 3/8
13/07/2025, 18:33 HTML Tables
You can have as many rows as you like in a table; just make sure that the number of
cells areTutorials
the same in Exercises
each row. Services Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
Note: There are times when a row can have less or more cells than another. You will
learn about that in a later chapter.
Table Headers
Sometimes you want your cells to be table header cells. In those cases use the <th>
tag instead of the <td> tag:
Example
Let the first row be table header cells:
<table>
<tr>
<th>Person 1</th>
<th>Person 2</th>
<th>Person 3</th>
</tr>
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
<tr>
<td>16</td>
<td>14</td>
<td>10</td>
</tr>
</table>
https://www.w3schools.com/html/html_tables.asp 4/8
13/07/2025, 18:33 HTML Tables
Try it Yourself »
Tutorials Exercises Services Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
By default, the text in <th> elements are bold and centered, but you can change that
with CSS.
?
Exercise
What is the correct tag name for a table-cell in HTML?
<tc>
<td>
<tr>
Submit Answer »
https://www.w3schools.com/html/html_tables.asp 5/8
13/07/2025, 18:33 HTML Tables
<tbody>
Tutorials Groups the body content in a table
Exercises Services Sign In
For a complete list of all available HTML tags, visit our HTML Tag Reference.
❮ Previous Next ❯
https://www.w3schools.com/html/html_tables.asp 6/8
13/07/2025, 18:33 HTML Tables
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
COLOR PICKER
PLUS SPACES
Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
https://www.w3schools.com/html/html_tables.asp 7/8
13/07/2025, 18:33 HTML Tables
How To Tutorial
Top References
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
W3.CSS Reference
Bootstrap Reference
PHP Reference
HTML Colors
Java Reference
Angular Reference
jQuery Reference
https://www.w3schools.com/html/html_tables.asp 8/8