English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML 参考手册

HTML 标签大全

HTML: <th> etiqueta

HTML <th>标签定义了一个标题单元格,该标题单元格可以出现在HTML表的第一行中。浏览器将在 <th>标签中找到的文本呈现为粗体,居中对齐的文本。该标签通常也称为 <th>元素。

在线示例

 HTML 表格,带有两个表头单元格和两个数据单元格:

!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML th标签的使用(基础教程网 oldtoolbag.com)</title>
</head>
<body>
<table border="1">
  <tr>
    <th>Column 1 Heading</th>
    <th>Column 2 Heading</th>
    <th>Column 3 Heading</th>
  </tr>
  <tr>
    <td>Data in Column</td> 1, Row 2</td>
    <td>Data in Column</td> 2, Row 2</td>
    <td>Data in Column</td> 3, Row 2</td>
  </tr>
</table>
</body>
</html>
Test to see ‹/›


In this HTML5In the document example, we used the <table> tag to create a table that has3columns and2rows.1row has3The row defined by the2Rows are defined by the <td> tag.

Browser compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers support the <th> tag.

Tag definition and usage instructions

<th> tag defines a table header cell in an HTML table.

HTML tables have two types of cells:

  • Table header cell - Contains header information (by <th> element created)

  • standard cell - Contains data (by <td> elements create)

The text in the <th> element is usually presented in bold and centered.

The text in the <td> element is usually left-aligned plain text.

<th> tag is a title cell that can appear in the first row of an HTML table. You can define the <th> tag within the <thead> tag, which has some advantages in browsers, but it is optional.

Tips and notes

Tip:If you need to span content across multiple rows or columns, use the colspan and rowspan attributes!

HTML 4.01 and HTML5differences between

HTML 5 No longer supports HTML 4.01 Some attributes in

Attribute

AttributeValueDescription
abbrtextHTML5 Não suportado. Define the abbreviated version of the content in the table header cell.
alignleft
 right
 center
 justify
 char
HTML5 Não suportado. Define the horizontal alignment of the content in the table header cell.
axiscategory_nameHTML5 Não suportado. Classify the table header cell.
bgcolorrgb(x,x,x)
#xxxxxx
colorname
HTML5 Não suportado. HTML 4.01 Descontinuado. Define the background color of the table header cell.
charcharacterHTML5 Não suportado. Define the character according to which the content is aligned.
charoffnumberHTML5 Não suportado. Define the offset of the alignment character.
colspannumberDefine the number of columns that the table header cell can span.
headersheader_idDefine one or more table header cells associated with the table header cell.
heightpixels
%
HTML5 Não suportado. HTML 4.01 Descontinuado. Define the height of the table header cell.
nowrapnowrapHTML5 Não suportado. HTML 4.01 Descontinuado. Define whether the content in the table header cell wraps.
rowspannumberDefine the number of rows that the table header cell can span.
scopecol
 colgroup
 row
 rowgroup
Define se a célula de cabeçalho é a cabeça de linha, coluna, grupo de linhas ou grupo de colunas.
valigntop
 middle
 bottom
 baseline
HTML5 Não suportado. Define a alinhamento vertical do conteúdo da célula de cabeçalho.
widthpixels
%
HTML5 Não suportado. HTML 4.01 Descontinuado. Define o largura da célula de cabeçalho.

Atributos globais

A etiqueta <th> suporta Atributos globais do HTML.

Atributos de evento

A etiqueta <th> suporta todos Atributos de evento do HTML.

Mais exemplos

Células de tabela que se estendem por linhas ou colunas
Este exemplo demonstra como definir células de tabela que se estendem por linhas ou colunas.

Etiquetas dentro da tabela
Este exemplo demonstra como exibir elementos dentro de diferentes elementos.

Margem de célula (Cell padding)
Este exemplo demonstra como usar o preenchimento de célula para criar espaço entre o conteúdo da célula e sua borda.

Espaçamento de célula (Cell spacing)
Este exemplo demonstra como usar o espaçamento de célula para aumentar o espaço entre as células.

Artigos relacionados

Tutorial HTML:Tabela HTML

Manual de Referência do DOM HTML:Objeto Th