Basic Table Elements and Attributes part 3 (tr attribute)
Table of Content:
We already discuss about these below attributes
- The
align
Attribute - The
bgcolor
Attribute - The
border
Attribute - The
cellpadding
Attribute - The
cellspacing
Attribute - The
dir
Attribute - The
frame
Attribute - The
rules
Attribute - The
summary
Attribute - The
width
Attribute
- The
<table>
Element Creates a Table - The
align
Attribute - The
bgcolor
Attribute - The
border
Attribute - The
cellpadding
Attribute - The
cellspacing
Attribute - The
dir
Attribute - The
frame
Attribute - The
rules
Attribute - The
summary
Attribute - The
width
Attribute - The
<tr>
Element Contains Table Rows - The
align
Attribute - The
bgcolor
Attribute - The
char
Attribute - The
charoff
Attribute - The
valign
Attribute - The
<td>
and<th>
Elements Represent Table Cells - The
abbr
Attribute - The
align
Attribute - The
axis
Attribute - The
bgcolor
Attribute - The
char
Attribute - The
charoff
Attribute - The
colspan
Attribute - The
headers
Attribute - The
height
Attribute - The
nowrap
Attribute - The
rowspan
Attribute - The
scope
Attribute - The
valign
Attribute - The
width
Attribute - Adding a
<caption>
to a Table - Spanning Columns Using the
colspan
Attribute - Spanning Rows Using the
rowspan
Attribute - Splitting Up Tables Using a Head, Body, and Foot
- Grouping Columns Using the
<colgroup>
Element - Columns Sharing Styles Using the
<col>
Element - Nested Tables
The align
Attribute
The align
attribute specifies the position of the content of all of the cells in the row.
align = "alignment"
By default, any <td> cells are usually left - aligned, whereas any <th> cells are usually centered.
The table that follows lists the possible values for the align attribute:
Value | Purpose | Example |
left | Content is left - aligned. | align = "left" |
right | Content is right - aligned. | align = "right" |
center | Content is centered horizontally within the cell. | align = "center" |
justify | Text within the cell is justified to fill the cell. | align = "justify" |
char | Cell contents are aligned horizontally around the first instance of a specific character (for example, numbers could be aligned around the first instance of a decimal point). | align = "char" |
Example 1: align="left"
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |
Live Preview
Example 2: align="right"
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |
Live Preview
Example 3: align="center"
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |
Live Preview
Example 4: align="justify"
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |
Live Preview
Example 5: align="char"
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |
Live Preview
The bgcolor
Attribute
The bgcolor attribute sets the background color for the row.
bgcolor = "red"
Example 5: bgcolor = "pink"
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |
Live Preview
The char
Attribute
The char attribute specifies the alignment of the content in a cell to a character.
The char attribute can only be used if the align attribute is set to "char".
The default value of char is the decimal-point character of the page language.
The <td> char attribute is not supported in HTML5.
$10.00
Name | Salary |
---|---|
Jakir | $100.78 |
Sabir | $1200.78 |
Sourav | $1030.78 |
Rohan | $1300.78 |
Rumman | $1400.78 |
Live Preview
The charoff
Attribute
charoff = "2"
The <td> charoff attribute is not supported in HTML5.
The charoff attribute sets the number of characters the content will be aligned from the character specified by the char attribute. For example, if it is given a value of 2 , then the elements are aligned with the character that is two characters along from the one specified by the char attribute. It can also take a negative value.
The charoff attribute can only be used if the char attribute is specified and the align attribute is set to "char".
Name | Salary |
---|---|
Xman | $1000.00 |
Kreesh | $1043.00 |
this attribute is not supported at the time of this writing, and there is no requirement for browsers to support it.
Live Preview
The valign
Attribute
The purpose of the HTML valign attribute is to define the vertical alignment of the content of a table cell.
HTML valign attribute supports col, colgroup, tbody, td, tfoot, th, thead, tr elements.
ElementName valign = "value"
The table that follows shows the possible values of the valign attribute:
Value | Description |
---|---|
top | Sets the vertical alignment of cell content top. |
middle | Sets the vertical alignment of cell content center. |
bottom | Sets the vertical alignment of cell content bottom. |
baseline | If set, the first text line occurs on a baseline common to all cells in the row. |
Example 1: valign="top"
Student Code | Percentage of marks | Grade | Remarks |
---|---|---|---|
S001 | 92 | A+ | Excellent |
S002 | 76 | B+ | Good |
Live Preview
Example 2: valign="middle"
Student Code | Percentage of marks | Grade | Remarks |
---|---|---|---|
S001 | 92 | A+ | Excellent |
S002 | 76 | B+ | Good |
Live Preview
Example 3: valign="bottom"
Student Code | Percentage of marks | Grade | Remarks |
---|---|---|---|
S001 | 92 | A+ | Excellent |
S002 | 76 | B+ | Good |
Live Preview
Example 4: valign="baseline"
Student Code | Percentage of marks | Grade | Remarks |
---|---|---|---|
S001 | 92 | A+ | Excellent |
S002 | 76 | B+ | Good |