Versión en español




HTML td tag


Note: If you don't know what a tag is and/or how you must use it we recommend you to read our HTML tags and attributes tutorial that you can find in our HTML tutorials section.

Description

The HTML td tag defines a regular cell in a table (HTML table tag).

Attributes

id (name)

The "id" attribute assigns an identifier to the associated element. This identifier must be unique in the document and can be used to refer to that element.

Example:

Code begin <p id="paragraph1">This is the first paragraph named as paragraph1. To dynamically change its properties use this identifier.</p>Code end


class (cdata)

The "class" attribute assigns a class name (or a list of class names separated by spaces) to the container element. It's used with style sheets and tells the browser the class to which the element is associated with. A class gives visual attributes to elements.

Example:

Code begin <p class="references">This article is based on the book "Wind in the trees" by Jhon L. Brooks</p>

<p class="references important">This article is based on the book "Wind in the trees" by Jhon L. Brooks... and is more important than the one before.</p>Code end


style (style)

Defines a visual style of this element. Is a better practice to define styles attributes in external style sheets grouping them in classes. Attributes in the "style" parameter must preserve this order "name : value" and be separated by a semi-colon.

If you're writing XHTML code it's recommended not to use this attribute and try style sheet classes (with the "class" attribute).

Example:

Code begin <p style="color: #0000FF; font-size: 12pt">This is a paragraph with a defined style</p>
<p>And this is another text without style.</p>Code end


title (text)

Indicates a title for the element. Used to give a short description about the element that is usually shown as a "tool tip" when the user put the mouse pointer over the element.

Example:

Code View
<a title="HTMLQuick.com" href="http://www.htmlquick.com">HTML code</a> HTML code

lang (langcode)

Specifies the language of an element's content. The default value in "unknown".

When writing XHTML code the syntax "xml:lang" represents a preferred alternative in XHTML 1.0 and a replacement in XHTML 1.1 (e.g., xml:lang="en").

Example:

Code begin <p lang="en">This is a paragraph in english.</p>
<p lang="es">Este es un p&aacute;rrafo en espa&ntilde;ol.</p>Code end


dir

Specifies the text direction of the element's contents and attribute values, as well as tables directionality. It has two possible values that are case insensitive:
Example:

Code begin <q lang="he" dir="rtl">...a Hebrew quotation...</q>Code end


bgcolor (character)

This attribute have been deprecated

Defines a color to be used as a background.

align

Defines the alignment of the content of a cell. Can be one of the following values (case-insensitive):
Example:

Code View
<table border="1" summary="Example table showing the use of the align attribute.">
<tr><td style="width: 7.6em">Left</td></tr>
<tr><td style="width: 7.6em" align="center">Center</td></tr>
<tr><td style="width: 7.6em" align="right">Right</td></tr>
</table>
Left
Center
Right

valign

Specifies the vertical alignment of the data in a cell. Works exactly like "align" attribute but for vertical space. The possible values are (case-insensitive):
Example:

Code View
<table border="1" summary="Example table showing the use of the valign attribute.">
<tr>
<td>1<br />2<br />3<br />4</td>
<td valign="top">23.065</td>
<td>324.432</td>
<td valign="bottom">45.8745</td>
</tr>
</table>
1
2
3
4
23.065 324.432 45.8745

char (character)

Specifies a single character that will act as axis for text alignment.
Note: Browsers are not required to support this attribute.

charoff (length)

Specifies the offset to the first occurrence of the alignment character on each line. Take into account the text direction (dir).
Note: Browsers are not required to support this attribute.

headers (idref)

Contains a space-separated list of id's corresponding to other cells that provide header information for this cell.

scope

Specifies a group of cells for which this cell will provide header information. Possible values (case-insensitive):

abbr (text)

Provides an abbreviated version of a cell's content that may be used by browsers in some cases instead of the content itself.

axis (cdata)

Groups cells into conceptual categories that can be considered to form axes in an n-dimensional space. Browsers may provide some functionality to display and relate these categories.

rowspan (number)

Specifies the number of rows spanned by this cell. The value "0" means that spans all rows from it's position to the last row of the container section (HTML thead tag, HTML tbody tag or HTML tfoot tag).

Example:

Code View
<table border="1" summary="Example table showing the use of the rowspan attribute.">
<tr><td rowspan="2">Cell1</td><td>Cell2</td></tr>
<tr><td>Cell3</td></tr>
</table>
Cell1Cell2
Cell3

colspan (number)

Specifies the number of columns spanned by this cell. The value "0" means that spans all columns from it's position to the last column of the container section (HTML colgroup tag).

Example:

Code View
<table border="1" summary="Example table showing the use of the colspan attribute.">
<tr><td>Cell1</td><td>Cell2</td></tr>
<tr><td colspan="2">Cell3</td></tr>
</table>
Cell1Cell2
Cell3

wrap

This attribute have been deprecated

When present this boolean attribute tells the browser to don't automatically wrap text content in this cell.

Remember that boolean attributes must be defined as attr_name="attr_name" to be XHTML code compliant.

width (length)

This attribute have been deprecated

Provides a hint of the desired with for the cell. Bowsers may change the with according to the space availability.

height (length)

This attribute have been deprecated

Provides a hint of the desired with for the cell. Bowsers may change the with according to the space availability.


Events

See complete list and information about events in HTML


Examples

In this example we define a table with grouped columns, grouped rows and many attributes for each tag that will define a visual style.
Code View
<table border="1" frame="border" rules="groups" summary="Functionality of HTML files in different versions of Internet Explorer">
<caption>Representation of how HTML files works in different versions of Internet Explorer</caption>
<colgroup align="center"></colgroup>
<colgroup></colgroup>
<colgroup align="center" span="2"></colgroup>
<thead>
<tr>
<th>File</th>
<th>Name</th>
<th>4.0</th>
<th>5.0</th>
</tr>
</thead>
<tfoot>
<tr>
<th>File</th>
<th>Name</th>
<th>4.0</th>
<th>5.0</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>1</td>
<td>index.html</td>
<td>Ok</td>
<td>Ok</td>
</tr>
<tr>
<td>2</td>
<td>links.html</td>
<td>Ok</td>
<td>Ok</td>
</tr>
<tr>
<td>3</td>
<td>fullfunc.html</td>
<td>-</td>
<td>Ok</td>
</tr>
<tr>
<td>4</td>
<td>nofunc.html</td>
<td>Ok</td>
<td>Ok</td>
</tr>
<tr>
<td>5</td>
<td>panel.html</td>
<td>-</td>
<td>Ok</td>
</tr>
</tbody>
<tbody>
<tr>
<td>6</td>
<td>search.php</td>
<td>Ok</td>
<td>Ok</td>
</tr>
<tr>
<td>7</td>
<td>send.php</td>
<td>Ok</td>
<td>Ok</td>
</tr>
</tbody>
</table>
Representation of how HTML files works in different versions of Internet Explorer
File Name 4.0 5.0
File Name 4.0 5.0
1 index.html Ok Ok
2 links.html Ok Ok
3 fullfunc.html - Ok
4 nofunc.html Ok Ok
5 panel.html - Ok
6 search.php Ok Ok
7 send.php Ok Ok



Bypass footer options  |   Send to a friend Send to a friend  |  Post to del.icio.us Post to del.icio.us

Digg this page Digg this!  |  File on Furl File on Furl  |  Add to Yahoo! MyWeb Add to Yahoo! MyWeb

Bypass W3C declarations | 

Valid XHTML 1.0 Strict  |  Valid CSS Why should you trust us? Click the images on the left to see how seriously we write our own pages, then make your choice.

Level Triple-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0. This website gives its best effort to achieve the Level Triple-A Conformance, W3C-WAI Web Content Accessibility Guidelines 1.0. If you find any detail or error that we didn't see, don't hesitate and let us know.

The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect. -- Tim Berners-Lee, W3C Director and inventor of the World Wide Web.

 Link to us  |  Contact us  |  Beyond HTML  |  Tools and resources  |  Sitemap  |  Webmaster