如何在 HTML 中创建表格标题?
htmlweb developmentfront end technology更新于 2026/1/16 5:32:17
使用 HTML 中的 <thead> 标签创建表格标题。HTML <thead> 标签用于向表格添加标题。thead 标签与 tbody 标签和 tfoot 标签结合使用,用于确定表格的各个部分(标题、页脚和正文)。
HTML <thead> 标签还支持以下附加属性 −
| 属性 |
值 |
描述 |
|---|---|---|
| align |
right left center justify char |
已弃用 − 视觉对齐。 |
| char |
character |
已弃用− 指定文本对齐的字符。当 align = "char" 时使用 |
| charoff |
pixels or % |
已弃用− 指定相对于 char 属性指定的第一个字符的对齐偏移量(以像素或百分比值表示)。当 align = "char" 时使用 |
| valign |
top 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>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

