实例
一个简单的 HTML 表格,包含两行两列:
<table border="1"> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> </table>
定义和用法
<table> 标签定义 HTML 表格。
简单的 HTML 表格由 table 元素以及一个或多个 tr、th 或 td 元素组成。
tr 元素定义表格行,th 元素定义表头,td 元素定义表格单元。
更复杂的 HTML 表格也可能包括 caption、col、colgroup、thead、tfoot 以及 tbody 元素。
浏览器支持
元素 | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
<table> | Yes | Yes | Yes | Yes | Yes |
所有浏览器都支持 <table> 标签。
HTML 与 XHTML 之间的差异
在 HTML 4.01 中,table 元素的 "align" 和 "bgcolor" 属性是不被赞成使用的。
在 XHTML 1.0 Strict DTD,table 元素的 "align" 和 "bgcolor