HTML <td> Attribute

Attribute Value Description
abbr text Not supported in HTML5.
Specifies an abbreviated version of the content in a cell
align left
right
center
justify
char
Not supported in HTML5.
Aligns the content in a cell
axis category_name Not supported in HTML5.
Categorizes cells
bgcolor rgb(x,x,x)
#xxxxxx
colorname
Not supported in HTML5.
Specifies the background color of a cell
char character Not supported in HTML5.
Aligns the content in a cell to a character
charoff number Not supported in HTML5.
Sets the number of characters the content will be aligned from the character specified by the char attribute
colspan number Specifies the number of columns a cell should span
headers header_id Specifies one or more header cells a cell is related to
height pixels
%
Not supported in HTML5.
Sets the height of a cell
nowrap nowrap Not supported in HTML5.
Specifies that the content inside a cell should not wrap
rowspan number Sets the number of rows a cell should span
scope col
colgroup
row
rowgroup
Not supported in HTML5.
Defines a way to associate header cells and data cells in a table
valign top
middle
bottom
baseline
Not supported in HTML5.
Vertical aligns the content in a cell
width pixels
%
Not supported in HTML5.
Specifies the width of a cell

HTML <td> abbr Attribute

Use of the abbr attribute in an HTML table:

<table>
<tr>
<th>Toy manufacturer</th>
<th>Model</th>
</tr>
<tr>
<td>Bruder Toys</td>
<td abbr=”vehicle”>8970 Cross Country Vehicle</td>
</tr>
<tr>
<td>Bruder Toys</td>
<td abbr=”lorry”>0567 DHL Lorry</td>
</tr>
</table>

Try it Yourself »


Definition and Usage

The <td> abbr attribute is not supported in HTML5.

The abbr attribute specifies a shorter version of the content in a cell.


HTML <td> align Attribute

Right-align the content in a cell:

<table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td align=”right”>$100</td>
</tr>
</table>

Try it Yourself »


Definition and Usage

The align attribute specifies the horizontal alignment of the content in a cell.


HTML <td> axis Attribute

An HTML table with categorized cells:

<table>
<tr>
<th axis=”name”>Name</td>
<th axis=”contact”>Email</td>
<th axis=”contact”>Phone</td>
<th axis=”contact”>Address</td>
</tr>
<tr>
<td axis=”name”>John Doe</td>
<td axis=”contact”>someone@example.com</td>
<td axis=”contact”>+45342323</td>
<td axis=”contact”>Rosevn 56,4300 Sandnes,Norway</td>
</tr>
</table>

Try it Yourself »


Definition and Usage

The <td> axis attribute is not supported in HTML5.

The axis attribute is used to categorize cells.

The axis attribute can be used to group related columns of information.


HTML <td> bgcolor Attribute

Add background color to cells:

<table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td bgcolor=”#FF0000″>January</td>
<td bgcolor=”#00FF00″>$100</td>
</tr>
</table>

Try it Yourself »


Definition and Usage

The bgcolor attribute specifies the background color of a table cell.


HTML <td> char Attribute

Align the content of the “Savings” data cell to the “.” character:

<table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td align=”char” char=”.”>$100.00</td>
</tr>
<tr>
<td>February</td>
<td align=”char” char=”.”>$10.00</td>
</tr>
</table>

Try it Yourself »


Definition and Usage

The <td> char attribute is not supported in HTML5.

The char attribute specifies the alignment of the content in a cell to a character.

The char attribute can only be used if the align attribute is set to “char”.

The default value of char is the decimal-point character of the page language.


HTML <td> charoff Attribute

Align the content of the “Savings” data cell two characters to the right from the “.” character:

<table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td align=”char” char=”.” charoff=”2″>$100.00</td>
</tr>
<tr>
<td>February</td>
<td align=”char” char=”.” charoff=”2″>$10.00</td>
</tr>
</table>

Try it Yourself »


Definition and Usage

The <td> charoff attribute is not supported in HTML5.

The charoff attribute sets the number of characters the content will be aligned from the character specified by the char attribute.

The charoff attribute can only be used if the char attribute is specified and the align attribute is set to “char”.


HTML <td> colspan Attribute

An HTML table with a table cell that spans two columns:

<table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
<tr>
<td colspan=”2″>Sum: $180</td>
</tr>
</table>

Try it Yourself »


Definition and Usage

The colspan attribute defines the number of columns a cell should span.


HTML <td> headers Attribute

Specify the <th> element each <td> element is related to:

<table>
<tr>
<th id=”name”>Name</th>
<th id=”email”>Email</th>
<th id=”phone”>Phone</th>
<th id=”addr”>Address</th>
</tr>
<tr>
<td headers=”name”>John Doe</td>
<td headers=”email”>someone@example.com</td>
<td headers=”phone”>+45342323</td>
<td headers=”addr”>Rosevn 56,4300 Sandnes,Norway</td>
</tr>
</table>

Try it Yourself »


Definition and Usage

The headers attribute specifies one or more header cells a table cell is related to.


HTML <td> height Attribute

Two table cells with a predefined height:

<table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td height=”100″>January</td>
<td height=”100″>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>

Try it Yourself »


Definition and Usage

The height attribute specifies the height of a cell.

Normally, a cell takes up the space it needs to display the content. The height attribute is used to set a predefined height of a cell.


HTML <td> nowrap Attribute

A table cell with a nowrap attribute:

<table>
<tr>
<th>Poem</th>
<th>Poem</th>
</tr>
<tr>
<td nowrap>Never increase, beyond what is necessary, the number of entities required to explain anything</td>
<td>Never increase, beyond what is necessary, the number of entities required to explain anything</td>
</tr>
</table>

Try it Yourself »


Definition and Usage

The nowrap attribute is a boolean attribute.

When present, it specifies that the content inside a cell should not wrap.


HTML <td> rowspan Attribute

An HTML table with a table cell that spans two rows:

<table>
<tr>
<th>Month</th>
<th>Savings</th>
<th>Savings for holiday!</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
<td rowspan=”2″>$50</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>

Try it Yourself »

More “Try it Yourself” examples below.


Definition and Usage

The rowspan attribute specifies the number of rows a cell should span.


HTML <td> scope Attribute

The following example identifies two of the <th> elements as headers for columns, and two of the <td> elements as headers for rows:

<table>
<tr>
<th></th>
<th scope=”col”>Month</th>
<th scope=”col”>Savings</th>
</tr>
<tr>
<td scope=”row”>1</td>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td scope=”row”>2</td>
<td>February</td>
<td>$80</td>
</tr>
</table>

Try it Yourself »


Definition and Usage

The <td> scope attribute is not supported in HTML5.

The scope attribute defines a way to associate header cells and data cells in a table.

The scope attribute identifies whether a cell is a header for a column, row, or group of columns or rows.


HTML <td> valign Attribute

Vertical align the content inside <td> elements:

<table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td valign=”bottom”>January</td>
<td valign=”bottom”>$100</td>
</tr>
</table>

Try it Yourself »


Definition and Usage

The valign attribute specifies the vertical alignment of the content in a cell.


HTML <td> width Attribute

Table cells with a predefined width:

<table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td width=”70%”>January</td>
<td width=”30%”>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>

Try it Yourself »


Definition and Usage

The width attribute specifies the width of a table cell.

Normally, a cell takes up the space it needs to display the content. The width attribute is used to set a predefined width of a cell.