EN
HTML table basic example
6
points
In this article we would like to show you how to create simple HTML table.
Example 1
Run below html code to get table shown on below screenshot:
Src code:
// ONLINE-RUNNER:browser;
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
table {
width: 100%;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
</style>
</head>
<body style="height: 180px;">
<h2>HTML basic table example</h2>
<table>
<tr>
<th>ID</th>
<th>Username</th>
<th>User age</th>
</tr>
<tr>
<td>1</td>
<td>Amy</td>
<td>25</td>
</tr>
<tr>
<td>2</td>
<td>Tom</td>
<td>27</td>
</tr>
</table>
</body>
</html>