HTML tr Tag
The <tr> tag is used to define a row in an HTML table. The <tr> element contains multiple <th> or <td> elements.
Syntax
<tr>.....</tr>
Attributes
Example: This example describe the basic usage of the <tr> tag in HTML Table.
html
<!DOCTYPE html> < html > < head > < title >tr tag</ title > < style > body { text-align: center; } h1 { color: green; } th { color: blue; } table, tbody, td { border: 1px solid black; border-collapse: collapse; } </ style > </ head > < body > < center > < h1 >w3wiki</ h1 > < h2 >tr Tag</ h2 > < table > < thead > <!-- tr tag starts here --> < tr > < th >Name</ th > < th >User Id</ th > </ tr > <!-- tr tag end here --> </ thead > < tbody > < tr > < td >Shashank</ td > < td >@shashankla</ td > </ tr > < tr > < td >w3wiki</ td > < td >@Beginner</ td > </ tr > </ tbody > </ table > </ center > </ body > </ html > |
Explanation
- HTML page styled with centered layout, headings in green, table 3 rows and cells in black border.
- Table created with “Name” and “User ID” headers in thead.
- Table body populated with user information in rows and cells.
- CSS styles applied to headers and table elements for layout and border styles.
- Page displays “w3wiki” heading, “tr Tag” subheading, and user data in a structured table format.
Output:
Note : The <tr>
tag also supports the Global Attributes and the Event Attributes in HTML.
Supported Browsers
The browsers supported by HTML <tr> Tag are listed below:
- Google Chrome 1 and above
- Edge 12 and above
- Firefox 1 and above
- Apple Safari
- Opera
Contact Us