Write an HTML program to create a table of student marks
Description: Create a table that shows the name and marks of three students, with a header row and borders.
Hint:
- Use
thfor the header cells andtdfor the data cells. - A table has no border by default, so add a border with CSS.
HTML program to create a table
<!DOCTYPE html>
<html lang="en">
<head>
<title>Marks</title>
<style>
table { border-collapse: collapse; }
th, td { border: 1px solid #999; padding: 8px; }
</style>
</head>
<body>
<table>
<tr><th>Name</th><th>Marks</th></tr>
<tr><td>Robin</td><td>85</td></tr>
<tr><td>Maria</td><td>92</td></tr>
<tr><td>John</td><td>78</td></tr>
</table>
</body>
</html>
Output in the browser:
Output in the browser
| Name | Marks |
|---|---|
| Robin | 85 |
| Maria | 92 |
| John | 78 |
How it works
- Each
tris a row. The first row has header cells (th), which are bold. border-collapse: collapsejoins the borders of neighbour cells into one line.
Read HTML Tables.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |