Use Of TR Tag
<TR> tag is used to create rows in HTML Tables. <TR> is the opening tag to start a row and </TR> is a closing tag to end a row. You can place pairs of <td>...</td> tags to create data cells in a row within the <tr>...</tr> tags.
for example to create a row with only one cell containing data "Apples", we will use the following html code.and Mangoes respectively:
<tr>
<td>Apples</td>
</tr>
Apples |
<tr>
<td>Apples</td>
<td>Mangoes</td>
</tr>
Apples | Mangoes |
<tr>
<th>Employee</th>
<th>Salary</th>
</tr>
Employee | Salary |
---|
Attributes of TR Tag
1. align
It is used to define the horizontal alignment of text in cells, in a particular row. The possible values are:
left: The text is aligned to the left.
center: The text is centered.
right: The text is aligned to the right.
justify: The text is justified to both, left and right, margins.
Example HTML code
<table border="1">
<tr align="right">
<td width="100">Salary</td>
<td width="100">10000</td>
</tr>
</table>
<tr align="right">
<td width="100">Salary</td>
<td width="100">10000</td>
</tr>
</table>
Salary | 10000 |
2. valign
It defines vertical alignment of the text with in cells in a row. Possible values are:top: The text is aligned to the top.
middle: The text is vertically centered. This is the default value.
bottom: The text is aligned to the botom.
3. bgcolor
It defines the background color that will be used as background of all the cells inside the row.For example, if we use <tr bgcolor="green">, all cells in this row will have a green background as shown below.
<table border="1">
<tr bgcolor="green">
<td>Apple</td>
<td>Banana</td>
<td>mango</td>
</tr>
</table>
Apple | Banana | mango |
Comments