Back Main GuestBook Contact Music (JS) Appendix

<TD></TD> - Data Table Cells

This tag defines a table cell; it encompasses all of the cell's contents. "TD" stands for "Table Data"--this is a data cell. Header cells use a different tag: <TH>. However, if a cell is both a header cell and a data cell, it should be of the <TD> variety.

HTML 4.0 Specification § 11.2.6

Attributes for <TD>

  %coreattrs %i18n %events

Structural Attributes

  colspan= [CN]
Gives number of columns to span.

This attribute defines the number of table columns the cell spans. The default value is "1"
If a cell spans more than one column, then it takes the place of more than one cell in the row. For instance, if I had a 4×4 table, I could give the first cell in the first row colspan=3. It would span three columns, putting one long cell where three were before. The fourth cell would remain untouched. The code for that row would include only two cell tags: <TD colspan=3> and <TD>

The value of colspan figures in the cell count for a row.


  rowspan= [CI]
Gives number of rows to span.
This attribute defines the number of rows a cell spans. The default value is "1".
If a cell spans from one row into the next, that fact must be taken into account when coding the next row: Suppose I have a table with four columns and Cell D in the first row, fourth column, has rowspan=2. In the next row I will put only three cell tags--one for the each of the first three columns. The fourth column is taken up by an extension of the cell from the first row.

Presentational Attributes

D height= [CN]
Gives height by pixel.
Gives height by percent of table's height.
This attribute gives a recommendation of the cell's height--if the content doesn't fit in the height specified, or there is some other conflict, the cell may grow to fit the content.

D width= [CN]
Gives width by pixel.
Gives width by percent of table's width.
This attribute gives a recommended cell width--if the cell's content doesn't fit, or there is some other conflict, the cell's width might be increased.

D nowrap (nowrap=nowrap) [CI]
This attribute disables text wrap within the cell; the entire contents of the cell will be forced onto one line.

  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 the cell's first line's baseline with the first baselines of all other cells in the row with the same alignment value.
This attriute specifies the vertical alignment of the cell's content.
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 cell's contents. 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 cell, overriding any colors set by other tags.
See also background color rules.

Samples:

A table with two rows and four columns: The first cell in the first row spans three columns; the second cell in the first row (located in the fourth column) spans two rows, from the first into the second.

Cell A Cell B
Cell C Cell D Cell E

Here is the code for the samples above:

<P>A table with two rows and four columns: The first cell in the first row spans three columns; the second cell in the first row (located in the fourth column) spans two rows, from the first into the second.</P>

<TABLE border=1>
<TR>
    <TD colspan=3>Cell A</TD>
    <TD rowspan=2>Cell B</TD>
</TR>
<TR>
    <TD>Cell C</TD>
    <TD>Cell D</TD>
    <TD>Cell E</TD>
</TR>
</TABLE>