Tag <tr> In HTML
This post will discuss Tag Tr with relevant examples and references. This post contains much information that you can use as a learning tool.
The <tr> tag in HTML stands for “table row.” It is used to define a row within an HTML table. The <tr> tag is usually used in combination with the <table> and <td> tags to create tables with multiple rows and columns.
The following HTML table has five rows and two cells:
Example:
You can use the table, table row, and table column elements in a table and align the content inside the cells with CSS:
Example:
Adding the background-color to a table row and table with CSS:
Example:
Here is an example of the vertical align content with in <tr> tag using CSS:
Example:
The <th> element describe the table headers above the <tr> tag:
Example:
An example of a caption for a table is shown here:
Example:
You can set more than two rows and two columns by using the rowspan and colspan attributes. Here is how:
Example:
Tag Tr Uses
The Tag Tr <tr> indicates a row within an HTML table.
An element with a <tr> tag might include one or more <th> or <td> tags.
Here are some common uses of the <tr> tag:
- The <tr> tag is used to create rows in an HTML table. Each <tr> tag represents a new row in the table.
- The <tr> tag is used in combination with the <td> tag to define the data in each cell of a table row. Each <td> tag represents a new cell in the row.
- The <tr> tag can be used with CSS to apply styles to table rows, such as setting the background color or font size.
- The <tr> tag can be used with the <thead>, <tbody>, and <tfoot> tags to group table rows into sections. This can make it easier to style or manipulate certain parts of the table.
Browser Compatibility
Element | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
<tr> | Yes | Yes | Yes | Yes | Yes |
Attributes
Global
The Tag <tr> also accommodates Global Attributes in HTML.
Event
The Tag Tr <tr> also accepts Event Attributes in HTML.
Predefined CSS
Most browsers will likely display the Tag Tr <tr> element with the values listed below:
tr { display: table-row; vertical-align: inherit; border-color: inherit; }
HTML Tag Tr Advantages
The <tr> tag in HTML provides several advantages that make it a useful tag for creating tables:
- Tables created with the <tr> tag provide a structured way to present data, which makes it easier for users to read and understand.
- Tables created with the <tr> tag can be easily read by screen readers, making the content accessible to visually impaired users.
- Tables created with the <tr> tag can be easily customized with CSS, allowing designers to style them to match the look and feel of their website.
- Tables created with the <tr> tag can be made responsive with CSS, allowing them to adapt to different screen sizes and devices.
- Tables created with the <tr> tag are supported by all modern web browsers, ensuring that the content is accessible to a wide range of users.