Table
is one of the elements in HTML that we can use to create tables in our web pages.
table
elementAn HTML table
element consists of some tags and attributes necessary to build a table. Those tags are as follows:
<td>
: defines a standard data cell in an HTML table.<tr>
: defines a row in an HTML table.<th>
: defines a header cell in an HTML table.As shown in the illustration above, a <table>
tag uses multiple elements to create a simple table in HTML. The following syntax shows how to create a table with three rows and one element in each row.
<table>
<tr>
<th>....</th>
</tr>
<tr>
<td>...</td>
</tr>
<tr>
<td>...</td>
</tr>
</table>
Consider the following example code that demonstrates how to create a table in HTML.
In the implementation above, we have made three data entries using the <td>
(John
, Jessica
, and Billy
), along with their respective ages.
The <th>
tag creates headings for Name
and Age.
Both the <th>
and <td>
tags are included inside the <tr>
tag to group them in a single row.
We use