Define a row in a table by using a <tr> tag in a document. This tag is used to define a row in an HTML table. The tr element contains multiple th or td elements.
Syntax:
<tr> ... </tr>Example: In this example, a table row in HTML5, utilizes the <tr> tag within the <tbody> section of the table. Each <tr> tag encloses table cells that define the content for each column. Use CSS for styling, ensuring consistent borders and alignment across cells and headers.
<!DOCTYPE html>
<html>
<head>
<title>
How to define row of a table
</title>
<style>
body {
text-align: center;
}
h1 {
color: green;
}
th {
color: blue;
}
table,
tbody,
td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
</head>
<body>
<center>
<h2>
Define
a row in a table
</h2>
<table>
<thead>
<!-- tr tag starts here -->
<tr>
<th>Name</th>
<th>User Id</th>
</tr>
<!-- tr tag end here -->
</thead>
<tbody>
<tr>
<td>Shashank</td>
<td>@shashankla</td>
</tr>
<tr>
<td>GeeksforGeeks</td>
<td>@geeks</td>
</tr>
</tbody>
</table>
</center>
</body>
</html>
Output:

Supported Browsers
- Google Chrome: 129
- Firefox: 130
- Opera: 110
- Safari: 17.6