How do we add a table row in HTML?

HTMLFront End TechnologyWeb Development

Kickstart HTML, CSS and PHP: Build a Responsive Website

Featured

59 Lectures 8.5 hours

Web Design for Beginners: Build Websites in HTML & CSS 2022

68 Lectures 8 hours

Complete HTML/CSS Course 2022

Featured

47 Lectures 12.5 hours

Use the <tr> tag to add a table row. The HTML <tr> tag is used for specifying a table row within a table.

The HTML <tr> tag also supports the following additional attributes −

Attribute
Value
Description
Align
right
left
center
justify
char
Deprecated − Visual alignment.
bgcolor
rgb(x,x,x)
#hexcode
colorname
Deprecated − Specifies the background color of the table cell.
Char
Character
Deprecated − Specifies which character to align text on. Used when align = "char".
Charoff
pixels or %
Deprecated − Specifies an alignment offset (either in pixels or percentage value) against the first character as specified with the char attribute. Used when align = "char".
Valign
top
middle
bottom
baseline
Deprecated − Vertical alignment

Example

You can try to run the following code to learn how to add a row in an HTML table −

<!DOCTYPE html>
<html>
<title>HTML tr Tag</title>
<body>
<table border = "1">
<tr>
<th>Cricketers</th>
<th>Ranking</th>
</tr>
<tr>
<td>Virat Kohli</td>
<td>1</td>
</tr>
<tr>
<td>AB de Villiers</td>
<td>2</td>
</tr>
</table>
</body>
</html>
Updated on 02-Mar-2020 12:29:39