HTML tr Tag
Last Updated :
15 Nov, 2023
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
- align: Align the content.
- bgcolor: Specify the background of the row
- char: Align the content to a character
- charoff: Set the number of character
- valign: Vertical align the content
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 >GeeksforGeeks</ h1 >
< h2 >tr Tag</ h2 >
< table >
< thead >
< tr >
< th >Name</ th >
< th >User Id</ th >
</ tr >
</ thead >
< tbody >
< tr >
< td >Shashank</ td >
< td >@shashankla</ td >
</ tr >
< tr >
< td >GeeksforGeeks</ td >
< td >@geeks</ 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 “GeeksforGeeks” 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
Share your thoughts in the comments
Please Login to comment...