如何在 HTML 中创建表格标题?
htmlweb developmentfront end technology更新于 2025/8/14 7:40:17
使用 HTML 中的 <th> 标签创建标题。HTML <th> 标签用于指定表格中的标题单元格或表格标题。
以下是 − 的属性
| 属性 | 值 | 描述 |
|---|---|---|
| abbr | abbreviated_text | 已弃用 − 指定标题单元格中内容的缩写版本。 |
| align | right left center justify char | 已弃用 − 标题单元格中的内容对齐。 |
| axis | Name | 已弃用 − 为此 th 指定一个类别。 |
| bgcolor | rgb(x,x,x) #hexcode colorname | 已弃用 − 指定标题单元格的背景颜色。 |
| char | Character | 已弃用 − 指定文本对齐的字符。当 align = "char" 时使用 |
| charoff | pixels or % | 已弃用 − 指定相对于 char 属性指定的第一个字符的对齐偏移量(以像素或百分比值表示)。当 align = "char" 时使用 |
| colspan | Number | 指定标题单元格跨越的列数。 |
| headers | Id | 指定与单元格相关的一个或多个标题单元格。 |
| height | Pixels | 已弃用 − 指定标题单元格的高度。 |
| nowrap | Nowrap | 已弃用 − 防止文本自动换行。 |
| rowspan | rowspan | 指定标题单元格跨越的行数。 |
| scope | col colgroup row rowgroup | 此属性用于标题单元格并指定将使用此标题信息的单元格。 |
| valign | top middle bottom baseline | Deprecated − Vertical alignment. |
| width | pixels or % | 已弃用− 指定表头单元格的宽度 |
示例
您可以尝试运行以下代码来了解如何在 HTML 中创建表格标题 −
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<h3>Result</h3>
<table>
<th>Marks</th>
<th>Student</th>
<tr>
<td>600</td>
<td>Amit</td>
</tr>
<tr>
<td>400</td>
<td>Anil</td>
</tr>
</table>
</body>
</html>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

