Latest web development tutorials

HTML <td> tag

Examples

A simple HTML form with two cells:

<table border="1">
<tr>
<td>Cell A</td>
<td>Cell B</td>
</tr>
</table>

try it"
(For more examples, see the bottom of the page)

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support <td> tag.


Tag definitions and instructions

<Td> tag defines a standard HTML table cells.

HTML table, there are two types of cells:

  • Header cells - contains header information (the <th> create elements)
  • Standard cells - contains data (created by the <td> element)

<Th> element is typically rendered as bold text and centered.

<Td> element is usually plain text left-aligned text.


Tips and Notes

Tip: If youneed content across multiple rows or columns, use colspan and rowspan attributes!


Differences between HTML 4.01 and HTML5

HTML 5 is no longer some HTML 4.01 attributes support.


Attributes

属性 描述
abbr text HTML5 不支持。规定单元格中内容的缩写版本。
align left
right
center
justify
char
HTML5 不支持。规定单元格内容的水平对齐方式。
axis category_name HTML5 不支持。对单元格进行分类。
bgcolor rgb(x,x,x)
#xxxxxx
colorname
HTML5 不支持。HTML 4.01 已废弃。 规定单元格的背景颜色。
char character HTML5 不支持。规定根据哪个字符来进行内容的对齐。
charoff number HTML5 不支持。规定对齐字符的偏移量。
colspan number 规定单元格可横跨的列数。
headers header_id 规定与单元格相关联的一个或多个表头单元格。
height pixels
%
HTML5 不支持。HTML 4.01 已废弃。
设置单元格的高度。
nowrap nowrap HTML5 不支持。HTML 4.01 已废弃。
规定单元格中的内容是否折行。
rowspan number 设置单元格可横跨的行数。
scope col
colgroup
row
rowgroup
HTML5 不支持。定义将表头单元格与数据单元格相关联的方法。
valign top
middle
bottom
baseline
HTML5 不支持。规定单元格内容的垂直排列方式。
width pixels
%
HTML5 不支持。HTML 4.01 已废弃。 规定单元格的宽度。


Global Properties

<td> tag supports HTML global properties .


Event Properties

<td> tag supports HTML event properties .


Examples

Try - Example

Table title
This example demonstrates how to display table headers.

Empty Cells
This example demonstrates how to use the "& nbsp;" no content processing cell.

Table with headings
This example demonstrates with a title (caption) form.

Tags within the table
This example demonstrates how to display elements inside other elements.

Interbank across columns or table cell
This example demonstrates how to define cross or across columns of a table cell.


related articles

HTML Tutorial: HTML table

HTML DOM Reference: Td objects