HTML <table> 标签

定义和用法

<table> 标签定义 HTML 表格。

简单的 HTML 表格由 table 元素以及一个或多个 tr、th 或 td 元素组成。

tr 元素定义表格行,th 元素定义表头,td 元素定义表格单元。

更复杂的 HTML 表格也可能包括 caption、col、colgroup、thead、tfoot 以及 tbody 元素。

实例

一个简单的 HTML 表格,包含两行两列:

<table border="1">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table>

TIY

HTML 与 XHTML 之间的差异

在 HTML 4.01 中,table 元素的 "align" 和 "bgcolor" 属性是不被赞成使用的。

在 XHTML 1.0 Strict DTD,table 元素的 "align" 和 "bgcolor" 属性是不被支持的。

可选的属性

DTD 指示此属性允许在哪种 DTD 中使用。S=Strict, T=Transitional, F=Frameset.

属性描述DTD
align
  • left
  • center
  • right

不赞成使用。请使用样式代替。

规定表格相对周围元素的对齐方式。

TF
bgcolor
  • rgb(x,x,x)
  • #xxxxxx
  • colorname

不赞成使用。请使用样式代替。

规定表格的背景颜色。

TF
border pixels 规定表格边框的宽度。 STF
cellpadding
  • pixels
  • %
规定单元边沿与其内容之间的空白。 STF
cellspacing
  • pixels
  • %
规定单元格之间的空白。 STF
frame
  • void
  • above
  • below
  • hsides
  • lhs
  • rhs
  • vsides
  • box
  • border
规定外侧边框的哪个部分是可见的。 STF
rules
  • none
  • groups
  • rows
  • cols
  • all
规定内侧边框的哪个部分是可见的。 STF
summary text 规定表格的摘要。 STF
width
  • %
  • pixels
规定表格的宽度。 STF

标准属性

id, class, title, style, dir, lang, xml:lang

如需完整的描述,请访问标准属性

事件属性

onclick, ondblclick, onmousedown, onmouseup, onmouseover, 
onmousemove, onmouseout, onkeypress, onkeydown, onkeyup
出自:http://www.w3school.com.cn/tags/tag_table.asp
原文地址:https://www.cnblogs.com/mfryf/p/3118393.html