HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
A simple HTML table with three rows; one header row and two data rows
The <tr>
tag defines a row in an HTML table.
A <tr>
element contains one or more <th> or
<td> elements.
Element | |||||
---|---|---|---|---|---|
<tr> | Yes | Yes | Yes | Yes | Yes |
The <tr>
tag also supports the Global Attributes in HTML.
The <tr>
tag also supports the Event Attributes in HTML.
How to align content inside <tr> (with CSS):
<table style="width:100%">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr style="text-align:right">
<td>January</td>
<td>$100</td>
</tr>
</table>
How to add background-color to a table row (with CSS):
<table>
<tr style="background-color:#FF0000">
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
How to vertical align content inside <tr> (with CSS):
<table style="height:200px">
<tr
style="vertical-align:top">
<th>Month</th>
<th>Savings</th>
</tr>
<tr style="vertical-align:bottom">
<td>January</td>
<td>$100</td>
</tr>
</table>
How to create table headers:
<table>
<tr>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
</tr>
<tr>
<td>John Doe</td>
<td>john.doe@example.com</td>
<td>123-45-678</td>
</tr>
</table>
How to create a table with a caption:
<table>
<caption>Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>
How to define table cells that span more than one row or one column:
<table>
<tr>
<th>Name</th>
<th>Email</th>
<th colspan="2">Phone</th>
</tr>
<tr>
<td>John Doe</td>
<td>john.doe@example.com</td>
<td>123-45-678</td>
<td>212-00-546</td>
</tr>
</table>
HTML tutorial: HTML Tables
HTML DOM reference: TableRow object
CSS Tutorial: Styling Tables
Most browsers will display the <tr>
element with the following default values:
tr {
display: table-row;
vertical-align: inherit;
border-color: inherit;
}