多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# HTML &lt;td&gt; 标签 ## 实例 一个简单的 HTML 表格,包含两行两列: ``` <table border="1"> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> </table> ``` ## 浏览器支持 | IE | Firefox | Chrome | Safari | Opera | | --- | --- | --- | --- | --- | 所有浏览器都支持 &lt;td&gt; 标签。 ## 定义和用法 &lt;td&gt; 标签定义 HTML 表格中的标准单元格。 HTML 表格有两类单元格: * 表头单元 - 包含头部信息(由 th 元素创建) * 标准单元 - 包含数据(由 td 元素创建) td 元素中的文本一般显示为正常字体且左对齐。 ## HTML 与 XHTML 之间的差异 在 HTML 4.01 中,td 元素的 "bgcolor"、"height"、"width" 以及 "nowrap" 是不被赞成使用的。 在 XHTML 1.0 Strict DTD 中,td 元素的 "bgcolor"、"height"、"width" 以及 "nowrap" 是不被支持的。 ## 提示和注释 提示:请使用 colspan 和 rowspan 属性来实现内容横跨多个行或列。 ## 可选的属性 | 属性 | 值 | 描述 | | --- | --- | --- | | [abbr](/tags/att_td_abbr.asp "HTML &lt;td&gt; 标签的 abbr 属性") | _text_ | 规定单元格中内容的缩写版本。 | | [align](/tags/att_td_align.asp "HTML &lt;td&gt; 标签的 align 属性") | `left` `right` `center` `justify` `char` | 规定单元格内容的水平对齐方式。 | | [axis](/tags/att_td_axis.asp "HTML &lt;td&gt; 标签的 axis 属性") | *category_name* | 对单元进行分类。 | | [bgcolor](/tags/att_td_bgcolor.asp "HTML &lt;td&gt; 标签的 bgcolor 属性") | _rgb(x,x,x)_ _#xxxxxx_ _colorname_ |不赞成使用。请使用样式取而代之。规定单元格的背景颜色。 | | [char](/tags/att_td_char.asp "HTML &lt;td&gt; 标签的 char 属性") | _character_ | 规定根据哪个字符来进行内容的对齐。 | | [charoff](/tags/att_td_charoff.asp "HTML &lt;td&gt; 标签的 charoff 属性") | _number_ | 规定对齐字符的偏移量。 | | [colspan](/tags/att_td_colspan.asp "HTML &lt;td&gt; 标签的 colspan 属性") | _number_ | 规定单元格可横跨的列数。 | | [headers](/tags/att_td_headers.asp "HTML &lt;td&gt; 标签的 headers 属性") | *header*cells'*id* | 规定与单元格相关的表头。 | | [height](/tags/att_td_height.asp "HTML &lt;td&gt; 标签的 height 属性") | _pixels_ _%_ | 不赞成使用。请使用样式取而代之。规定表格单元格的高度。 | | [nowrap](/tags/att_td_nowrap.asp "HTML &lt;td&gt; 标签的 nowrap 属性") | nowrap | 不赞成使用。请使用样式取而代之。规定单元格中的内容是否折行。 | | [rowspan](/tags/att_td_rowspan.asp "HTML &lt;td&gt; 标签的 rowspan 属性") | _number_ | 规定单元格可横跨的行数。 | | [scope](/tags/att_td_scope.asp "HTML &lt;td&gt; 标签的 scope 属性") | `col` `colgroup` `row` `rowgroup` | 定义将表头数据与单元数据相关联的方法。 | | [valign](/tags/att_td_valign.asp "HTML &lt;td&gt; 标签的 valign 属性") | `top` `middle` `bottom` `baseline` | 规定单元格内容的垂直排列方式。 | | [width](/tags/att_td_width.asp "HTML &lt;td&gt; 标签的 width 属性") | _pixels_ _%_ | 不赞成使用。请使用样式取而代之。规定表格单元格的宽度。 | ## 全局属性 &lt;td&gt; 标签支持 [HTML 中的全局属性](/tags/html_ref_standardattributes.asp)。 ## 事件属性 &lt;td&gt; 标签支持 [HTML 中的事件属性](/tags/html_ref_eventattributes.asp)。 ## 相关页面 HTML DOM 参考手册:[TableData 对象](/jsref/dom_obj_tabledata.asp "HTML DOM TableData 对象")