html tr tag

Definition of HTML tr tag

HTML tr tag is used to show HTML table row. A table can contain many numbers of rows. We can define the HTML table row using this tag.


Table can display with rows and columns. Each row can have any number of cells (columns). Let’s explain HTML tr tag with the topics given in the table:


Syntax:

The syntax showing the start and end tr tag to show HTML table row. In each tr tag, there can be any number of table cells.


Table with one row

This is the example showing one row. The example contains the country name with national game.

Output

Name of country with national game:

India Hockey

Table with more than one row

This is the example showing more than one row. The example contains the name of players with country name.

Output

Name of cricket players:

Name Team
Virat Kohli India
Chris Gayle West Indies
Lasith Malinga Sri Lanka
Dwayne Bravo West Indies

List of attributes of HTML tr tag

Sr. No. Attribute Name Description
1 align
  • align the table content to the specified location.
  • The value for this can be:
    • left
    • right
    • center
    • justify
    • char
2 bgcolor
  • The bgcolor attribute defines the background color of the table cell.
  • the value for this can be:
    • color name
    • hexcode(eg #ccc)
    • rgb color code (rgb(x, x, x))
3 char
  • this attribute can only be use when the value of align attribute is char (align=”char”). This can be useful when you want to specify the character to align.
  • the value for this can be any character.
4 charoff
  • Use this attribute only after you specify align=”char”. This defines an alignment offset against the first character.
  • the value for this can be:
    • pixel (eg. 10px)
    • percentage (eg. 2%)
5 valign
  • this aligns text vertically in the specified location.
  • the value for this can be:
    • top
    • bottom
    • middle
    • baseline

Resources and References of HTML table row

1. W3C Specification.
2. HTML living standard
3. W3C project using Github


Leave a Reply

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