summaryrefslogtreecommitdiff
path: root/devdocs/html/element%2Fthead.html
blob: 2c4ce7d33d0124b258541a1510de198d022f18b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<header><h1>&lt;thead&gt;: The Table Head element</h1></header><div class="section-content"><p>The <code>&lt;thead&gt;</code> <a href="../index">HTML</a> element defines a set of rows defining the head of the columns of the table.</p></div>
<h2 id="try_it">Try it</h2>
<div class="section-content"><iframe class="interactive is-tabbed-taller-height" height="200" src="https://interactive-examples.mdn.mozilla.net/pages/tabbed/thead.html" title="MDN Web Docs Interactive Example" loading="lazy"></iframe></div>
<h2 id="attributes">Attributes</h2>
<div class="section-content"><p>This element includes the <a href="../global_attributes">global attributes</a>.</p></div>
<h3 id="deprecated_attributes">Deprecated attributes</h3>
<div class="section-content"><dl> <dt id="align">
<a href="#align"><code>align</code></a> <abbr class="icon icon-deprecated" title="Deprecated. Not for use in new websites."> <span class="visually-hidden">Deprecated</span> </abbr>
</dt> <dd> <p>This <a href="https://developer.mozilla.org/en-US/docs/Glossary/Enumerated">enumerated</a> attribute specifies how horizontal alignment of each cell content will be handled. Possible values are:</p> <ul> <li>
<code>left</code>, aligning the content to the left of the cell</li> <li>
<code>center</code>, centering the content in the cell</li> <li>
<code>right</code>, aligning the content to the right of the cell</li> <li>
<code>justify</code>, inserting spaces into the textual content so that the content is justified in the cell</li> <li>
<code>char</code>, aligning the textual content on a special character with a minimal offset, defined by the <a href="#char"><code>char</code></a> and <a href="#charoff"><code>charoff</code></a> attributes.</li> </ul> <p>If this attribute is not set, the <code>left</code> value is assumed.</p> <div class="notecard warning" id="sect1"> <p><strong>Warning:</strong> Do not use this attribute as it is obsolete (not supported) in the latest standard.</p> <ul> <li>To align values, use the CSS <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/text-align"><code>text-align</code></a> property instead.</li> </ul> </div> </dd> <dt id="bgcolor">
<a href="#bgcolor"><code>bgcolor</code></a> <abbr class="icon icon-deprecated" title="Deprecated. Not for use in new websites."> <span class="visually-hidden">Deprecated</span> </abbr>
</dt> <dd> <p>This attribute defines the background color of each column cell. It accepts a 6-digit hexadecimal color or a named color. Alpha transparency is not supported.</p> <div class="notecard note" id="sect2"> <p><strong>Note:</strong> Do not use this attribute, as it is non-standard. The <code>thead</code> element should be styled using the CSS <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/background-color"><code>background-color</code></a> property, which can be applied to any element, including the <code>thead</code>, <a href="tr"><code>&lt;tr&gt;</code></a>, <a href="td"><code>&lt;td&gt;</code></a> and <a href="th"><code>&lt;th&gt;</code></a> elements.</p> </div> </dd> <dt id="char">
<a href="#char"><code>char</code></a> <abbr class="icon icon-deprecated" title="Deprecated. Not for use in new websites."> <span class="visually-hidden">Deprecated</span> </abbr>
</dt> <dd> <p>This attribute is used to set the character to align the cells in a column on. Typical values for this include a period (.) when attempting to align numbers or monetary values. If <a href="#align"><code>align</code></a> is not set to <code>char</code>, this attribute is ignored.</p> <div class="notecard note" id="sect3"> <p><strong>Note:</strong> Do not use this attribute as it is obsolete (and not supported) in the latest standard.</p> </div> </dd> <dt id="charoff">
<a href="#charoff"><code>charoff</code></a> <abbr class="icon icon-deprecated" title="Deprecated. Not for use in new websites."> <span class="visually-hidden">Deprecated</span> </abbr>
</dt> <dd> <p>This attribute is used to indicate the number of characters to offset the column data from the alignment characters specified by the <strong>char</strong> attribute.</p> <div class="notecard note" id="sect4"> <p><strong>Note:</strong> Do not use this attribute as it is obsolete (and not supported) in the latest standard.</p> </div> </dd> <dt id="valign">
<a href="#valign"><code>valign</code></a> <abbr class="icon icon-deprecated" title="Deprecated. Not for use in new websites."> <span class="visually-hidden">Deprecated</span> </abbr>
</dt> <dd> <p>This attribute specifies the vertical alignment of the text within each row of cells of the table header. Possible values for this attribute are:</p> <ul> <li>
<code>baseline</code>, which will put the text as close to the bottom of the cell as it is possible, but align it on the <a href="https://en.wikipedia.org/wiki/Baseline_%28typography%29" target="_blank">baseline</a> of the characters instead of the bottom of them. If characters are all of the size, this has the same effect as <code>bottom</code>.</li> <li>
<code>bottom</code>, which will put the text as close to the bottom of the cell as it is possible;</li> <li>
<code>middle</code>, which will center the text in the cell;</li> <li>
<code>top</code>, which will put the text as close to the top of the cell as it is possible.</li> </ul> <div class="notecard note" id="sect5"> <p><strong>Note:</strong> Do not use this attribute as it is obsolete (and not supported) in the latest standard: instead set the CSS <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align"><code>vertical-align</code></a> property on it.</p> </div> </dd> </dl></div>
<h2 id="examples">Examples</h2>
<div class="section-content"><p>See <a href="table"><code>&lt;table&gt;</code></a> for examples on <code>&lt;thead&gt;</code>.</p></div>
<h2 id="technical_summary">Technical summary</h2>
<div class="section-content"><figure class="table-container"><div class="_table"><table class="properties"> <tbody> <tr> <th scope="row"><a href="../content_categories">Content categories</a></th> <td>None.</td> </tr> <tr> <th scope="row">Permitted content</th> <td>Zero or more <a href="tr"><code>&lt;tr&gt;</code></a> elements.</td> </tr> <tr> <th scope="row">Tag omission</th> <td> The start tag is mandatory. The end tag may be omitted if the <a href="thead" aria-current="page"><code>&lt;thead&gt;</code></a> element is immediately followed by a <a href="tbody"><code>&lt;tbody&gt;</code></a> or <a href="tfoot"><code>&lt;tfoot&gt;</code></a> element. </td> </tr> <tr> <th scope="row">Permitted parents</th> <td> A <a href="table"><code>&lt;table&gt;</code></a> element. The <a href="thead" aria-current="page"><code>&lt;thead&gt;</code></a> must appear after any <a href="caption"><code>&lt;caption&gt;</code></a> or <a href="colgroup"><code>&lt;colgroup&gt;</code></a> element, even implicitly defined, but before any <a href="tbody"><code>&lt;tbody&gt;</code></a>, <a href="tfoot"><code>&lt;tfoot&gt;</code></a> and <a href="tr"><code>&lt;tr&gt;</code></a> element. </td> </tr> <tr> <th scope="row">Implicit ARIA role</th> <td><code><a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/rowgroup_role">rowgroup</a></code></td> </tr> <tr> <th scope="row">Permitted ARIA roles</th> <td>Any</td> </tr> <tr> <th scope="row">DOM interface</th> <td><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableSectionElement"><code>HTMLTableSectionElement</code></a></td> </tr> </tbody> </table></div></figure></div>
<h2 id="specifications">Specifications</h2>
<div class="_table"><table class="standard-table">
<thead><tr><th scope="col">Specification</th></tr></thead>
<tbody><tr><td><a href="https://html.spec.whatwg.org/multipage/tables.html#the-thead-element">HTML Standard <br><small># the-thead-element</small></a></td></tr></tbody>
</table></div>
<h2 id="browser_compatibility">Browser compatibility</h2>
<div class="_table"><table>
<thead>
<tr id="bct-browser-type">
<th></th>
<th colspan="6">Desktop</th>
<th colspan="6">Mobile</th>
</tr>
<tr id="bct-browsers">
<th></th>
<th>Chrome</th>
<th>Edge</th>
<th>Firefox</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
<th>WebView Android</th>
<th>Chrome Android</th>
<th>Firefox for Android</th>
<th>Opera Android</th>
<th>Safari on IOS</th>
<th>Samsung Internet</th>
</tr>
</thead>
<tbody>
<tr>
<th><code>thead</code></th>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">≤12.1</td>
<td class="bc-supports-yes"><details><summary>1</summary>Backgrounds applied to <code>&lt;thead&gt;</code> elements will be applied to each table cell, rather than the entire header. To mimic the behavior of other browsers, set the <code>background-attachment</code> CSS property to <code>fixed</code>.</details></td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">≤12.1</td>
<td class="bc-supports-yes"><details><summary>1</summary>Backgrounds applied to <code>&lt;thead&gt;</code> elements will be applied to each table cell, rather than the entire header. To mimic the behavior of other browsers, set the <code>background-attachment</code> CSS property to <code>fixed</code>.</details></td>
<td class="bc-supports-yes">1.0</td>
</tr>
<tr>
<th><code>align</code></th>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">15</td>
<td class="bc-supports-yes">3</td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">14</td>
<td class="bc-supports-yes">2</td>
<td class="bc-supports-yes">1.0</td>
</tr>
<tr>
<th><code>bgcolor</code></th>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">≤15</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">≤14</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">1.0</td>
</tr>
<tr>
<th><code>char</code></th>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-no">No</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">15</td>
<td class="bc-supports-yes">≤4</td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-no">No</td>
<td class="bc-supports-yes">14</td>
<td class="bc-supports-yes">≤3.2</td>
<td class="bc-supports-yes">1.0</td>
</tr>
<tr>
<th><code>charoff</code></th>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">15</td>
<td class="bc-supports-yes">≤4</td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">14</td>
<td class="bc-supports-yes">≤3.2</td>
<td class="bc-supports-yes">1.0</td>
</tr>
<tr>
<th><code>valign</code></th>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">15</td>
<td class="bc-supports-yes">3</td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">14</td>
<td class="bc-supports-yes">2</td>
<td class="bc-supports-yes">1.0</td>
</tr>
</tbody>
</table></div>
<h2 id="see_also">See also</h2>
<div class="section-content"><ul> <li>Other table-related HTML Elements: <a href="caption"><code>&lt;caption&gt;</code></a>, <a href="col"><code>&lt;col&gt;</code></a>, <a href="colgroup"><code>&lt;colgroup&gt;</code></a>, <a href="table"><code>&lt;table&gt;</code></a>, <a href="tbody"><code>&lt;tbody&gt;</code></a>, <a href="td"><code>&lt;td&gt;</code></a>, <a href="tfoot"><code>&lt;tfoot&gt;</code></a>, <a href="th"><code>&lt;th&gt;</code></a>, <a href="tr"><code>&lt;tr&gt;</code></a>;</li> <li>CSS properties and pseudo-classes that may be specially useful to style the <code>&lt;thead&gt;</code> element: <ul> <li>the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child"><code>:nth-child</code></a> pseudo-class to set the alignment on the cells of the column;</li> <li>the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/text-align"><code>text-align</code></a> property to align all cells content on the same character, like '.'.</li> </ul> </li> </ul></div><div class="_attribution">
  <p class="_attribution-p">
    &copy; 2005&ndash;2023 MDN contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>
    <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/thead" class="_attribution-link">https://developer.mozilla.org/en-US/docs/Web/HTML/Element/thead</a>
  </p>
</div>