Make your own free website on Tripod.com

Back Main GuestBook Contact Music (JS) Appendix

<TR></TR> - Table Rows

At the code level, HTML tables are defined by their rows, not their columns. The <TR> tag defines a row and contains the tags for the table cells (given by <TD> and <TH>) in that row. For instance, if I had a table with two rows and four colums (which means four cells in each row), I would wind up with two <TR> tags, each containing four <TD>s. Because HTML also allows individual cells to span rows, the number of table cell tags will not always be consistent. However, the cell count must be the same for every row in the table.

The cell count for each row is calculated by adding

  1. the colspan value of all the table cell tags (<TD> and <TH>)
  2. the colspan value of all the table cells that span into this row from another row via the rowspan attribute.

(The default value of colspan is "1".)

The cell count should be the same for every row in the table. If your table is not coming out quite right, check the cell counts, and don't forget to include cells that span into that row from above.

HTML 4.0 Specification § 11.2.5

Attributes for <TR>

  %coreattrs %i18n %events

Presentational Attributes

  valign= [CI]
  • middle
Specifies vertical centering of content within cells. This is the default value.
  • top
Specifies top of cells' content aligned with top of cell.
  • bottom
Specifies bottom of cells' content aligned with bottom of cell.
  • baseline
Specifies alignment of each cell's first line's baseline. Any cells in the row that override this value will not participate in the alignment.
This attriute specifies the vertical alignment of the content in each of the cells in the row.
See also Vertical Alignment Rules.

  align= [CI]
  • left
Specifies left alignment of cell contents.
  • center
Specifies centered cell content.
  • right
Specifies right alignment of cell contents.
  • justify
Specifies full justification of cell contents.
  • char
Specifies alignment of cell contents by the character given with char with all other cells in the same column that also have this type of alignment specified.
This attribute specifies the horizontal alignment of the contents of all the cells in the row. As for align=char, I've yet to see a browser that supports it.
See also Horizontal Alignment Rules

  char= [CI]
Gives character.
This attribute gives the character which the cell contents aligns on when align is set to char. The default value is the decimal point.

  charoff= [CI]
Gives position by pixel
Gives position by percent of cell width
This attribute controls the location of the character used in character alignment (align=char). The position of the character is charoff's value from the left edge of the cell for left-to-right cells and from the right edge for right-to-left cells. (The text direction is given by the dir attribute.)

D bgcolor= [CI]
Specifies the color in hexadecimal form.
Specifies the color by name.
This attribute controls the background color of the cells in the row, overriding any colors set in the <TABLE> tag.
See also background color rules.

Samples:

Table with two rows and four columns:

Cell A Cell B Cell C Cell D
Cell E Cell F Cell G Cell H
Cell I Cell J Cell K Cell L

Notice that in the following table, the second row has only two cell tags; however, the cell count is still 4 for both rows.

Cell A Cell B Cell C Cell D
Cell E Cell F

Here is the code for the sample above:

<p>Table with two rows and four columns:</p>
<TABLE border=1>
<TR>
    <TD>Cell A</TD>
    <TD>Cell B</TD>
    <TD>Cell C</TD>
    <TD>Cell D</TD>
</TR>
<TR>
    <TD>Cell E</TD>
    <TD>Cell F</TD>
    <TD>Cell G</TD>
    <TD>Cell H</TD>
</TR>
</TABLE>

<p>Notice that in the following table, the second row has only two cell tags; however, the cell count is still 4 for both rows.</p>
<TABLE border=1>
<TR>
    <TD>Cell A</TD>
    <TD>Cell B</TD>
    <TD>Cell C</TD>
    <TD rowspan=2>Cell D</TD>
</TR>
<TR>
    <TD colspan=2>Cell E</TD>
    <TD>Cell F</TD>
</TR>
</TABLE>