目录 搜索
Attributes accesskey (attribute) class (attribute) contenteditable (attribute) contextmenu (attribute) data-* (attribute) dir (attribute) draggable (attribute) dropzone (attribute) Global attributes hidden (attribute) id (attribute) itemid (attribute) itemprop (attribute) itemref (attribute) itemscope (attribute) itemtype (attribute) lang (attribute) slot (attribute) spellcheck (attribute) style (attribute) tabindex (attribute) title (attribute) translate (attribute) Elements a abbr address area article aside audio b base bdi bdo blockquote body br button canvas caption cite code col colgroup data datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 head header hr html i iframe img input input type="button" input type="checkbox" input type="color" input type="date" input type="datetime"-local input type="email" input type="file" input type="hidden" input type="image" input type="month" input type="number" input type="password" input type="radio" input type="range" input type="reset" input type="search" input type="submit" input type="tel" input type="text" input type="time" input type="url" input type="week" ins kbd label legend li link main map mark menu menuitem meta meter nav noscript object ol optgroup option output p param picture pre progress q rp rt rtc ruby s samp script section select slot small source span strong style sub summary sup table tbody td template textarea tfoot th thead time title tr track u ul var video wbr Miscellaneous Attributes Block-level elements CORS enabled image CORS settings attributes Element Inline elements Kinds of HTML content Link types Microdata Optimizing your pages for speculative parsing Preloading content Reference Supported media formats Using the application cache Obsolete acronym applet basefont big blink center command content dir element font frame frameset hgroup image input type="datetime" isindex keygen listing marquee nextid noframes plaintext strike tt xmp
文字

HTML <td> 元素 定义了包含数据的表的一个单元格。它参与表格模型

内容类别

没有。

允许的内容

Flow content.

标记遗漏

开始标记是强制性的。如果紧跟着一个<th>或<td>元素,或者在其父元素中没有更多的数据,则可以省略结束标记。

允许的父母

一个<tr>元素。

允许ARIA角色

任何

DOM接口

HTMLTableDataCellElement

属性

这个元素包含全局属性。

abbr

自HTML5以来已过时,此属性包含单元格内容的简短缩写描述。某些用户代理(例如语音阅读器)可以在内容本身之前呈现该描述。

注意:不要使用这个属性,因为它在最新的标准中已经过时了:取而代之,要么考虑通过一个独立的缩略内容本身来开始单元格内容,要么使用缩写内容作为单元格内容,并使用长内容作为单元格的描述把它放在title属性中。

align

自HTML4.01起弃用,自HTML5以来已废弃此枚举属性指定如何处理每个单元格内容的水平对齐。可能的值是:

  • left,将内容对齐到单元格的左侧

  • center,将内容集中在单元格中

  • right,将内容对齐到单元格的右侧

  • justify,在文本内容中插入空格以便内容在单元格中合理

  • char,在一个特殊的字符的文本内容以最小的偏移量,由定义的对准charcharoff属性未实现(参见错误2212)。

如果未设置此属性,则假定该值为left。

注意:不要使用这个属性,因为它在最新的标准中是过时的(不支持)。

  • 为了实现作为同样的效果leftcenterright,或justify值,使用CSS text-align就可以了财产。

  • 为了达到与charCSS3中的值相同的效果,可以使用值的值char作为text-align未实现属性的值。

axis自HTML5以来已过时此属性包含空格分隔字符串的列表。每个字符串都是此标头适用的一组单元格的标识。

注意:不要使用这个属性,因为它在最新的标准中已经过时:而是使用scope属性。

bgcolor该属性定义列的每个单元格的背景颜色。它是sRGB中定义的6位十六进制代码之一,以“#”为前缀。可以使用十六个预定义颜色字符串中的一个:


black = "#000000"


green = "#008000"


silver = "#C0C0C0"


lime = "#00FF00"


gray = "#808080"


olive = "#808000"


white = "#FFFFFF"


yellow = "#FFFF00"


maroon = "#800000"


navy = "#000080"


red = "#FF0000"


blue = "#0000FF"


purple = "#800080"


teal = "#008080"


fuchsia = "#FF00FF"


aqua = "#00FFFF"

使用说明:不要使用这个属性,因为它是非标准的,只能在某些版本的Microsoft Internet Explorer中实现:<td>元素应该使用CSS进行样式化。为了给bgcolor属性一个类似的效果,改用CSS属性background-color

char自HTML4.01开始弃用,自HTML5以来已过时此属性用于设置字符以对齐列中的单元格。典型值包括尝试对齐数字或货币值时的句点(。)。如果align未设置char,则忽略此属性。

注意:不要使用这个属性,因为它在最新的标准中是过时的(并且不被支持)。为了达到与charCSS3中相同的效果,可以使用char属性的字符集作为text-align属性Unimplemented 的值。

charoff自HTML4.01开始弃用,自HTML5以来已过时此属性用于指示从char属性指定的对齐字符中偏移列数据的字符数

注意:不要使用这个属性,因为它在最新的标准中是过时的(并且不被支持)。

colspan此属性包含一个非负整数值,指示单元格扩展的列数。它的默认值是1。高于1000的值将被视为不正确,并将被设置为默认值(1)。

headers该属性包含空格分隔的字符串列表,每个字符串对应于应用于此元素的元素的id属性<th>

rowspan该属性包含一个非负整数值,指示单元格延伸的行数。它的默认值是1; 如果它的值被设置为0,其延伸直到表部的端部(<thead><tbody><tfoot>,即使隐式定义的,该小区所属的值高于65534被限幅下降到65534。

scope过时于HTML5

valign已过时于HTML4.01,过时由于HTML5该属性指定表头的单元的每一行中的文本的垂直对齐。这个属性的可能值是:

  • baseline,这将把文本尽可能靠近单元格的底部,但将其对齐在字符的基线而不是底部。如果字符的大小相同,则与此效果相同bottom

  • bottom,这将使文本尽可能靠近单元格的底部

  • middle,将文本置于单元格中间。

  • top 这将使文本尽可能靠近单元格的顶部。

注意:不要使用这个属性,因为它在最新的标准中是过时的(并且不被支持):而是vertical-align在其上设置CSS 属性。

width自HTML4.01开始弃用,自HTML5以来已过时

此属性用于定义推荐的单元格宽度。属性cellspacing和cellpadding可能会增加额外的空间,而元素的<col>宽度也可能会有一些影响。一般来说,如果列的宽度太窄而不能正确显示某个特定的单元格,那么在显示时就会加宽它的单元格。

注意:不要在最新的标准中使用这个属性:改为设置CSS width属性。

例子

请参阅<table>页面上的例子<td>

规范

Specification

Status

Comment

HTML Living StandardThe definition of 'td element' in that specification.

Living Standard


HTML5The definition of 'td element' in that specification.

Recommendation


浏览器兼容性

Feature

Chrome

Edge

Firefox

Internet Explorer

Opera

Safari

Basic Support

1

(Yes)

1

(Yes)

(Yes)

(Yes)

abbr

1

(Yes)

1

(Yes)

(Yes)

(Yes)

align

?

(Yes)

No1

(Yes)

?

?

axis

1

(Yes)

1

(Yes)

(Yes)

(Yes)

bgcolor

?

No

No

(Yes)

?

?

char

?

(Yes)

No2

(Yes)

?

?

charoff

?

(Yes)

No2

(Yes)

?

?

colspan

1

(Yes)

1

(Yes)

(Yes)

(Yes)

headers

1

(Yes)

1

(Yes)

(Yes)

(Yes)

rowspan

1

(Yes)

1

(Yes)

(Yes)

(Yes)

scope

1

(Yes)

1

(Yes)

(Yes)

(Yes)

valign

?

(Yes)

No1

(Yes)

?

?

width

1

(Yes)

1

(Yes)

(Yes)

(Yes)

Feature

Android

Chrome for Android

Edge mobile

Firefox for Android

IE mobile

Opera Android

iOS Safari

Basic Support

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

abbr

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

align

?

?

(Yes)

No1

(Yes)

?

?

axis

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

bgcolor

?

?

No

No

(Yes)

?

?

char

?

?

(Yes)

No2

(Yes)

?

?

charoff

?

?

(Yes)

No2

(Yes)

?

?

colspan

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

headers

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

rowspan

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

scope

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

valign

?

?

(Yes)

No1

(Yes)

?

?

width

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

上一篇: 下一篇: