<TD>NN all   IE all   HTML 3.2
<TD>...</TD>End Tag: Optional
 

The TD element is a container for content that is rendered inside one cell of a TABLE element. One cell is the intersection of a column and row. Other elements related to the TD element are CAPTION, COL, COLGROUP, TABLE, TBODY, TFOOT, TH, THEAD, and TR. In addition to providing a wrapper for a cell's content, the TD element defines a number of visible attributes that apply to a single cell, often overriding similar attributes set in lesser-nested elements in the table.

Four attributes--ABBR, AXIS, HEADERS, and SCOPE--have been added to the HTML 4.0 specification in anticipation of nonvisual browsers that will use text-to-speech technology to describe content of an HTML page--a kind of "verbal rendering." Although these attributes are briefly described here for the sake of completeness, there is much more to their application in nonvisual browsers than is relevant in this book on Dynamic HTML. Consult the HTML 4.0 recommendation for more details.

 
Example
<TABLE COLS=3>
<THEAD>
<TR>
<TH>Time<TH>Event<TH>Location
</TR>
</THEAD>
<TBODY>
<TR>
<TD>7:30am-5:00pm<TD>Registration Open<TD>Main Lobby
</TR>
<TR>
<TD>9:00am-12:00pm<TD>Keynote Speakers<TD>Cypress Room
</TR>
</TBODY>
</TABLE>
 
Object Model Reference
IE [window.]document.all.elementID
ABBRNN n/a   IE n/a   HTML 4
ABBR="text"Optional
 

Provides an abbreviated string that describes the cell's content. This is usually a brief label that a nonvisual browser would speak to describe what the value of the cell represents.

 
Example
<TD ABBR="Main Event"> Keynote Speakers
 
Value
Any quoted string.
 
Default None.
ALIGNNN all   IE all   HTML 3.2
ALIGN="alignConstant"Optional
 

Establishes the horizontal alignment characteristics of content within the cell covered by the TD element. The HTML 4.0 specification defines settings for the ALIGN attribute that are not yet reflected in the CSS specification. Therefore, this ALIGN attribute is not fully deprecated as it is for many other elements. As a rule, alignment should be specified by style sheet wherever possible.

 
Example
<TD ALIGN="center">
 
Value
Navigator 4 and Internet Explorer 4 share the same attribute values, whereas HTML 4.0 has a couple more:
Value NN 4 IE 4 HTML 4.0
center
* * *
char
- - *
justify
- - *
left
* * *
right
* * *
The values center, left, and right are self-explanatory. The value justify is intended to space content so that text is justified down both left and right edges. For the value char, the CHAR attribute must also be set to specify the character on which alignment revolves. In the HTML 4.0 specification example, content that does not contain the character appears to be right-aligned to the location of the character in other rows of the same column.
 
Default left
 
Object Model Reference
IE [window.]document.all.elementID.align
AXISNN n/a   IE n/a   HTML 4
AXIS="text"Optional
 

Provides an abbreviated string that describes the cell's category. This is usually a brief label that a nonvisual browser would speak to describe what the value of the cell represents.

 
Example
<TD AXIS="event"> Keynote Speakers
 
Value
Any quoted string.
 
Default None.
BACKGROUNDNN n/a   IE 3   HTML n/a
BACKGROUND="URL"Optional
 

Specifies an image file that is used as a backdrop to the cell. Unlike normal images that get loaded into browser content, a background image loads in its original size (without scaling) and tiles to fill the available cell space. Smaller images download faster but are obviously repeated more often in the background. Animated GIFs are also allowable, but very distracting to the reader. When selecting a background image, be sure it is very muted in comparison to the main content so that the content stands out clearly. Background images, if used at all, should be extremely subtle.

 
Example
<TD BACKGROUND="watermark.jpg">
 
Value
Any valid URL to an image file, including complete and relative URLs.
 
Default None.
 
Object Model Reference
IE [window.]document.all.elementID.background
BGCOLORNN 3   IE 3   HTML 3.2
BGCOLOR="colorTripletOrName"Optional
 

Establishes a fill color (behind the text and other content) for the cell defined by the TD element.

 
Example
<TD BGCOLOR="yellow">
 
Value
A hexadecimal triplet or plain-language color name. A setting of empty is interpreted as "#000000" (black). See Appendix A for acceptable plain-language color names.
 
Default Varies with browser, browser version, and operating system.
 
Object Model Reference
IE [window.]document.all.elementID.bgColor
BORDERCOLORNN n/a   IE 3   HTML n/a
BORDERCOLOR="colorTripletOrName"Optional
 

The colors used to render some of the pixels that create the illusion of borders around cells and the entire table. Internet Explorer applies the color to all four lines that make up the interior border of a cell. Therefore, colors of adjacent cells do not collide.

 
Example
<TD BORDERCOLOR="green">
 
Value
A hexadecimal triplet or plain-language color name. A setting of empty is interpreted as "#000000" (black). See Appendix A for acceptable plain-language color names.
 
Default Varies with browser and operating system.
 
Object Model Reference
IE [window.]document.all.elementID.borderColor
BORDERCOLORDARK, BORDERCOLORLIGHTNN n/a   IE 3   HTML n/a
BORDERCOLORDARK="colorTripletOrName"
BORDERCOLORLIGHT="colorTripletOrName"
Optional
 

The 3-D effect of table borders in Internet Explorer is created by careful positioning of light and dark lines around the page's background or default color (see Figure 8-4 in the TABLE element discussion). You can independently control the colors used for the dark and light lines by assigning values to the BORDERCOLORDARK (left and top edges of the cell) and BORDERCOLORLIGHT (right and bottom edges) attributes.

Typically, you should assign complementary colors to the pair of attributes. There is also no rule that says you must assign a dark color to BORDERCOLORDARK. The attributes merely control a well-defined set of lines so you can predict which lines of the border change with each attribute.

 
Example
<TD BORDERCOLORDARK="darkred" BORDERCOLORLIGHT="salmon">
 
Value
A hexadecimal triplet or plain-language color name. A setting of empty is interpreted as "#000000" (black). See Appendix A for acceptable plain-language color names.
 
Default Varies with operating system.
 
Object Model Reference
IE [window.]document.all.elementID.borderColorDark
[window.]document.all.elementID.borderColorLight
CHARNN n/a   IE n/a   HTML 4
CHAR="character"Optional
 

The text character used as an alignment point for text within a cell. This attribute is of value only for the ALIGN attribute set to "char".

 
Example
<TD ALIGN="char" CHAR=".">
 
Value
Any single text character.
 
Default None.
CHAROFFNN n/a   IE n/a   HTML 4
CHAROFF="length"Optional
 

Sets a specific offset point at which the character specified by the CHAR attribute is to appear within a cell. This attribute is provided in case the browser default positioning does not meet with the design goals of the table.

 
Example
<TD ALIGN="char" CHAR="." CHAROFF="80%">
 
Value
Any length value in pixels or percentage of cell space.
 
Default None.
COLSPANNN all   IE all   HTML 3.2
COLSPAN="columnCount"Optional
 

The number of columns across which the current table cell should extend itself. For each additional column included in the COLSPAN count, one less TD element is required for the table row. If you set the ALIGN attribute to center or right, the alignment is calculated on the full width of the TD element across the specified number of columns. Unless the current cell also specifies a ROWSPAN attribute, the next table row returns to the original column count.

 
Example
<TD COLSPAN=2 ALIGN="center">
 
Value
Any positive integer, usually 2 or larger.
 
Default 1
 
Object Model Reference
IE [window.]document.all.elementID.colSpan
DATAFLDNN n/a   IE 4   HTML n/a
DATAFLD="columnName"Optional
 

Used with IE 4 data binding to associate a remote data source column name with the content of a table cell. A DATASRC (and optionally a DATAPAGESIZE) attribute must also be set for the enclosing TABLE element.

 
Example
<TABLE DATASRC="#DBSRC3" DATAPAGESIZE=5">
<TR>
  <TD><INPUT TYPE="text" DATAFLD="stockNum">
  <TD><INPUT TYPE="text" DATAFLD="qtyOnHand">
</TR>
</TABLE>
 
Value
Case-sensitive identifier.
 
Default None.
HEADERSNN n/a   IE n/a   HTML 4
HEADERS="cellIDList"Optional
 

Points to one or more TH or TD elements that act as column or row headers for the current table cell. The assigned value is a space-delimited list of ID attribute values that are assigned to the relevant TH elements. A nonvisual browser could read the cell's header before the content of the cell to help listeners identify the nature of the cell content.

 
Example
<TR>
<TH ID="hdr1">Product Number
<TH ID="hdr2">Description
</TR>
<TR>
<TD HEADERS="hdr1">0392
<TD HEADERS="hdr2">Round widget
</TR>
 
Value
A space-delimited list of case-sensitive IDs assigned to cells that act as headers to the current cell.
 
Default None.
HEIGHT, WIDTHNN all   IE all   HTML 3.2
HEIGHT="length"
WIDTH="length"
Optional
 

The rectangular dimensions of a cell that may be different from the default size as calculated by the browser. When the values for these attributes are less than the minimum space required to render the table cell content, the browser overrides the attribute settings to make sure that all content appears, even if it means that text lines word-wrap. You can also stretch the dimensions of a table beyond the browser-calculated dimensions. Extra whitespace appears inside table cells to make up the difference. If you specify just one of these attributes, the browser performs all necessary calculations to automatically adjust the dimension along the other axis. The cell must have some content assigned to it, or it may close up to minimum size.

Due to the regular nature of tables, if you set a custom height for one cell in a row, the entire row is set to that height; similarly, setting the width of a cell causes the width of all cells in the column to be the same size.

Both the HEIGHT and WIDTH attributes are deprecated in HTML 4.0 in favor of height and width style sheet attributes (which are not available for table cells in Navigator 4).

 
Example
<TD WIDTH="80%" HEIGHT=30>
 
Value
Any length value in pixels or percentage of available space.
 
Default Based on content size.
 
Object Model Reference
IE [window.]document.all.elementID.height
[window.]document.all.elementID.width
NOWRAPNN all   IE all   HTML 3.2
NOWRAPOptional
 

The presence of the NOWRAP attribute instructs the browser to render the cell as wide as is necessary to display a line of nonbreaking text on one line. Abuse of this attribute can force the user into a great deal of inconvenient horizontal scrolling of the page to view all of the content. The NOWRAP attribute is deprecated in HTML 4.0.

 
Example
<TD NOWRAP>
 
Value
The presence of this attribute sets its value to true.
 
Default false
 
Object Model Reference
IE [window.]document.all.elementID.noWrap
ROWSPANNN all   IE all   HTML 3.2
ROWSPAN="rowCount"Optional
 

The number of rows through which the current table cell should extend itself downward. For each additional row included in the ROWSPAN count, one less TD element is required for the next table row in that cell's position along the row.

 
Example
<TD ROWSPAN=2>
 
Value
Any positive integer, usually 2 or larger.
 
Default 1
 
Object Model Reference
IE [window.]document.all.elementID.rowSpan
SCOPENN n/a   IE n/a   HTML 4
SCOPE="scopeConstant"Optional
 

Used more with a TH element than with a TD element, the SCOPE attribute sets the range of cells (relative to the current cell) that behave as though the current cell is the header for those cells. For tables whose structure is quite regular, the SCOPE attribute is a simpler way of achieving what the HEADERS attribute does, without having to define ID attributes for the header cells.

 
Example
<TR>
<TH SCOPE="col">Product Number
<TH SCOPE="col">Description
</TR>
<TR>
<TD>0392
<TD>Round widget
</TR>
 
Value
One of four recognized scope constants:
col Current cell text becomes header text for every cell in the rest of the column.
colgroup Current cell text becomes header text for every cell in the rest of the COLGROUP element.
row Current cell text becomes header text for every cell in the rest of the TR element.
rowgroup Current cell text becomes header text for every cell in the rest of the TBODY element.
 
Default None.
VALIGNNN all   IE all   HTML 3.2
VALIGN="alignmentConstant"Optional
 

Determines the vertical alignment of content within the TD element. A value you set for an individual cell overrides the same attribute setting for outer containers, such as TR and TBODY.

 
Example
<TD VALIGN="bottom">
 
Value
Four constant values are recognized by both IE 4 and HTML 4.0: top | middle | bottom | baseline. With top and bottom, the content is rendered flush (or very close to it) to the top and bottom of the table cell. Set to middle (the default), the content floats perfectly centered vertically in the cell. When one cell's contents might wrap to multiple lines at common window widths (assuming a variable table width), it is advisable to set the VALIGN attribute to baseline. This assures that the character baseline of the first (or only) line of a cell's text aligns with the other cells in the row--usually the most aesthetically pleasing arrangement.
 
Default middle
 
Object Model Reference
IE [window.]document.all.elementID.vAlign
Hosted by uCoz