HTML Table


Tables

Tables allow to arrange the data in a proper manner. In table we have rows and columns.

In HTML table start with <table> and end with </table>, columns and rows are denoted with <th> and <tr>


Table Example

<!DOCTYPE html>
<html>
<head>
<title>Table Example</title>
</head>
<body>
<table>
<tr>
<td>Row 1</td>
<td>Row 1</td>
</tr>

<tr>
<td>Row 2</td>
<td>Row 2</td>
</tr>
</table>
</body>
</html>

Another Example with Head

<!DOCTYPE html>
<html>
<head>
<title>Table Example</title>
</head>
<body>
<table border = "1">
<tr>
<th>Name</th>
<th>Age</th>
</tr>

<tr>
<td>John</td>
<td>12</td>
</tr>

<tr>
<td>Eva</td>
<td>56</td>
</tr>

</table>

</body>
</html>


Table Cell

Anything between <td> and </td> are called Table Cell.<td> stands for table data

<!DOCTYPE html>
<html>
<head>
<title>Table Example</title>
</head>
<body>
<table>

<tr>
<td>John</td>
<td>12</td>
</tr>

</table>

</body>
</html>

Table Row

Table rows are start with <tr> and ends with </tr>.<tr> stands for table row

<!DOCTYPE html>
<html>
<head>
<title>Table Example</title>
</head>
<body>
<table>

<tr>
<td>John</td>
<td>12</td>
</tr>

</table>

</body>
</html>

Table Header

Table header are start with <th> and ends with </th>.<th> stands for table header

<!DOCTYPE html>
<html>
<head>
<title>Table Example</title>
</head>
<body>
<table>

<tr>
<th>Name</th>
<th>Age</th>
</tr>

</table>

</body>
</html>