HTML tr tag

HTML tr element defines the table row. tr contains table data in the table cells.

<table class="demoTable">
 <caption>The top populated countries</caption>
 <tr>
  <th> Countries </th>
  <th> Population </th>
  <th> Area</th>
  <th> Capital </th>
 </tr>
  
 <tr>
  <td> India </td>
  <td> 1,382,323,332 </td>
  <td> 3,287,263 </td>
  <td> New Delhi </td>
 </tr>
  <tr>
  <td> Mexico </td>
  <td> 129,163,276 </td>
  <td> 1,964,375 </td>
  <td> Mexico City </td>
 </tr>

</table>
</>
The top populated countries
Countries Population Area Capital
India 1,382,323,332 3,287,263 New Delhi
Mexico 129,163,276 1,964,375 Mexico City

Here, the tr defines a row of table. In the above example, the table has three rows defined by <tr> tags.

The caption element may also be used to write the title or the context of the table. It is centered automatically.

Tag omission

End tag (</tr>) may be omitted.

Global Attributes

All the global attributes are applicable on the tr element.



Was this article helpful?