HTML<tr> tag

HTML <tr> tag is used to define the rows in the table. The <tr> tag can consist one or more <th> head cells and <td> data cells to define a single row of HTML table.

The <tr> tag must be a direct child of <table> element or it can be nested child of <thead>, <tbody>, and <tfoot> elements.

Syntax

<tr>.......</tr>   

Following are some specifications about the HTML <tr> tag

DisplayInline
Start tag/End tagStart and End tag
UsageTable content

Example

<!DOCTYPE html>  

<html>  

<head>  

    <title>HTML tr tag</title>  

    <style>  

      table{  

        border-collapse: collapse;  

        margin-left: 350px;  

      }  

      th,td{  

        padding: 25px;}   

      th{  

        background-color: #005cb9;}  

      td{  

        background-color:#98f5ff;}  

    </style>  

</head>  

<body>  

 <h2>Example of tr tag</h2>  

 <table border="1">  

    <caption><b>Top Three performers of Winter Olympic Medals</b></caption>  

    <tr>  

    <th>Rank</th>  

    <th>Country</th>  

    <th>Total medals</th>  

        </tr>  

        <tr>  

    <td>1</td>  

    <td>Norway</td>  

    <td>329</td>  

        </tr>  

        <tr>  

    <td>2</td>  

    <td>United State</td>  

    <td>282</td>  

       </tr>  

    <tr>  

          <td>3</td>  

           <td>Germany</td>  

          <td>228</td>  

             </tr>  

 </table>  

</body>  

</html>

Output:

HTML tr tag

Attribute:

Tag-specific attributes:

AttributeValueDescription
alignright
left
center
justify
char
It determines the alignment of the content in the table row. (Not Supported in HTML5)
bgcolorrgb(x,x,x)
#xxxxx
color_name
It defines the background color of the table row. (Not Supported in HTML5)
charcharacterIt specifies the alignment of content to the character. (Not Supported in HTML5)
charoffnumberIt specifies the number of character the table row content will be aligned from the character, and which is specified by char attribute. (Not Supported in HTML5)
valignTop
Middle
Bottom
baseline
It specifies the vertical alignment of the table row content. (Not Supported in HTML5)

Global attribute:

The <tr> tag supports the Global attributes in HTML.

Event attribute:

The <tr> tag supports the Event attributes in HTML.

Supporting Browsers

Elementchrome browser Chromeie browser IEfirefox browser Firefoxopera browser Operasafari browser Safari
<tr>YesYesYesYesYes

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *