HTML标签属性
来源:互联网 发布:阿里云邮箱删除 编辑:程序博客网 时间:2024/06/06 00:15
一个简单的HTML表格由table元素及一个或多个tr、th 或 td 元素组成。
1.<table> </table>
定义 HTML 表格
2.<th> </th>
定义表头
3.<td> </td>
定义表格单元
4.<tr> </tr>
定义表格行
例:<html><body><table border="1"> <tr> <th>年</th> <th>月</th> <th>日</th> </tr> <tr> <td>2017年</td> <td>12月</td> <td>25日</td> </tr></table></body></html>
复杂的 HTML 表格可能包括 caption、col、colgroup、thead、tfoot 以及 tbody 等元素。
1.<caption> </caption>
定义表格标题
注意:caption 标签必须紧随 table 标签之后。只能对每个表格定义一个标题,一般情况下,标题会被居中于表格之上。
例:<html><body><table border="2"><caption>标题</caption><tr> <td>列表1</td> <td>列表2</td> <td>列表3</td></tr></table></body></html>
2.<col />
对表格中一个或多个列定义属性值
align 属性规定 div 元素中的内容的水平对齐方式
例:<html><body><table width="100%" border="1"> <col align="left" /> <col align="left" /> <col align="right" /> <tr> <th>No</th> <th>Title</th> <th>Data</th> </tr> <tr> <td>3476896</td> <td>My first HTML</td> <td>12月25日</td> </tr> <tr> <td>2489604</td> <td>My first CSS</td> <td>12月25日</td> </tr></table></body></html>
3.<colgroup> </colgroup>
对表格中的列进行组合,以便对其进行格式化
注意:
标签只能在 table 或 colgroup 元素中使用
标签只能在 table 元素中使用
4.<tfoot> </tfoot>
定义表格的页脚(脚注或表注)
5.<thead> </thead>
对 HTML 表格中的表头内容进行分组
6.<tbody> </tbody>
对 HTML 表格中的主体内容进行分组
注意:如果使用 thead、tfoot 以及 tbody 元素,就必须使用全部的元素。它们的出现次序是:thead、tfoot、tbody,这样浏览器就可以在收到所有数据前呈现页脚了。而且必须在 table 元素内部使用这些标签。
阅读全文