在HTML中如何创建表头?
使用HTML中的<thead>标记创建表头。HTML<thead>标记用于将标题添加到表中。thead标签与tbody标签和tfoot标签一起使用,以确定表的每个部分(页眉,页脚,正文)。
HTML<thead>标记还支持以下附加属性-
left
center
justify
char
middle
bottom
baseline
示例
您可以尝试运行以下代码以了解如何在HTML中实现<thead>标记-
<!DOCTYPE html> <html> <head> <title>HTML thead Tag</title> </head> <body> <table style = "width:100%" border = "1"> <thead> <tr> <td colspan = "4">This is the head of the table</td> </tr> </thead> <tfoot> <tr> <td colspan = "4">This is the foot of the table</td> </tr> </tfoot> <tbody> <tr> <td>Cell 1</td> <td>Cell 2</td> <td>Cell 3</td> <td>Cell 4</td> </tr> <tr> ...more rows here containing four cells... </tr> </tbody> <tbody> <tr> <td>Cell 1</td> <td>Cell 2</td> <td>Cell 3</td> <td>Cell 4</td> </tr> <tr> ...more rows here containing four cells... </tr> </tbody> </table> </body> </html>