HTML Tags

HTML <td> Tag

Topic: HTML5 Tags ReferencePrev|Next

Description

The <td> (short for table data) tag defines a data cell in a table. A Table cells may contain two types of information: header information and data.

  • The <th> element defines a cell that contains header information.
  • The <td> element defines a cell that contains data.

This distinction enables web browser to render header and data cells distinctly, even in the absence of style sheets. For example, header cell text rendered with a bold font while text inside the data cell rendered as a regular text.

The following table summarizes the usages context and the version history of this tag.

Parent: <tr>
Content: Block, inline, and text
Start/End Tag: Start tag: required, End tag: required
Version: HTML 3.2, 4, 4.01, 5

Syntax

The basic syntax of the <td> tag is given with:

HTML / XHTML: <td> ... </td>

The example below shows the <td> tag in action.

<table>
    <tr>
        <th>No.</th>
        <th>Name</th>
        <th>Email</th>
    </tr>
    <tr>
        <td>1</td>
        <td>John Carter</td>
        <td>[email protected]</td>
    </tr>
    <tr>
        <td>2</td>
        <td>Peter Parker</td>
        <td>[email protected]</td>
    </tr>
    <tr>
        <td>3</td>
        <td>John Rambo</td>
        <td>[email protected]</td>
    </tr>
</table>

Tag-Specific Attributes

The following table shows the attributes that are specific to the <td> tag.

Attribute Value Description
abbr text Obsolete Provide a short abbreviated description of the content of the cell.
align left
right
center
justify
char
Obsolete Specifies the alignment of cell contents.
axis text Obsolete Categorizes table cells.
bgcolor color Obsolete Sets the background color of a table cell.
char character Obsolete Sets the character to which cell contents should align.
charoff number Obsolete Defines the number of characters by which cell contents will be offset from the alignment characters specified by the char attribute.
colspan number Specifies the number of columns spanned by the current cell.
headers header-id Specifies one or more header cells a cell is related to.
height length Obsolete Sets the height of the table cell.
nowrap nowrap Obsolete This boolean attribute tells the browser to disable automatic text wrapping for this cell.
rowspan number Specifies the number of rows spanned by the current cell.
scope col
colgroup
row
rowgroup
Obsolete Specifies a way to associate header cells and data cells in a table.
valign top
middle
bottom
baseline
Obsolete Specifies the vertical alignment of content within a table cell.
width length Obsolete Sets the width of a table cell.

Global Attributes

Like all other HTML tags, the <td> tag supports the global attributes in HTML5.


Event Attributes

The <td> tag also supports the event attributes in HTML5.


Browser Compatibility

The <td> tag is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 2+
  • Apple Safari 1+
  • Opera 4+

Further Reading

See tutorial on: HTML Tables.

Other table-related tags: <table>, <thead>, <tfoot>, <tbody>, <caption>, <colgroup>, <col>, <tr>, <th>.

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties