Adding Table Heading to Rows
To add a table heading to rows in an HTML table, you can use the <th> element within the <tr> element. This is useful when you have data that represents headings for each row.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Basic HTML Table</title>
</head>
<body>
<table border="1">
<tr>
<th>Heading 1</th>
<th>Heading 2</th>
</tr>
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
<tr>
<td>Row 3, Column 1</td>
<td>Row 3, Column 2</td>
</tr>
</table>
</body>
</html>
Output:
How to Create Table in HTML?
HTML tables are essential for organizing and displaying data in a structured format on web pages. Creating a table in HTML is a fundamental skill for web developers. It is used for product information, presenting data analytics, or designing a pricing comparison chart, etc. This article provides a step-by-step guide on how to create tables in HTML.
Table of Content
- Elements of HTML Table
- Table Structure
- Basic Syntax of HTML Table
- Adding Table Heading to Rows
- HTML Table with thead, tbody, and tfoot Elements