HTML Tag - Create a Table in HTML
HTML table allows you to arrange data into rows and columns. They are commonly used to display tabular data like product listings, customer's details, financial reports, and so on.
You can create a table using the
<table>
element. Inside the <table>
element, you can use the <tr>
elements to create rows, and to create columns inside a row you can use the <td>
elements. You can also define a cell as a header for a group of table cells using the <th>
element.
The following example demonstrates the most basic structure of a table.
<html>
<head>
<title> Create a table</title>
</head>
<body>
<table>
<tr>
<th>No.</th>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>1</td>
<td>Peter Parker</td>
<td>16</td>
</tr>
<tr>
<td>2</td>
<td>Clark Kent</td>
<td>34</td>
</tr>
</table>
</body>
</html>
<head>
<title> Create a table</title>
</head>
<body>
<table>
<tr>
<th>No.</th>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>1</td>
<td>Peter Parker</td>
<td>16</td>
</tr>
<tr>
<td>2</td>
<td>Clark Kent</td>
<td>34</td>
</tr>
</table>
</body>
</html>
Copy This Code and Paste on the Notepad and Save as ... table.html
Now you got the