

#
要素について
| カテゴリー | なし |
| 利用場所 | “tr”要素の子要素として |
| 内容 | フロー・コンテンツ |
| タグの省略 | 直後に“th”要素か“td”要素が続く場合、もしくは親要素の中で後に続くコンテンツがない場合は終了タグを省略可能 |
“th”要素は表の見出しセルを表す要素です。
“td”要素は親要素となる“table”要素で表される見出しを含むセルを表します。表のデータを含むセルは“td”要素で表します。
“th”要素と“td”要素は配置された順に表の行に並べられます。書字方向が左から右の場合は左側から順に並びます。
サンプルコード
<table>
<thead>
<tr>
<th>県名</th>
<th>人口</th>
<th>面積(km<sup>2</sup>)</th>
</tr>
</thead>
<tbody>
<tr>
<th>徳島</th>
<td>723,096</td>
<td>4,146.75</td>
</tr>
<tr>
<th>香川</th>
<td>950,799</td>
<td>1,876.78</td>
</tr>
<tr>
<th>愛媛</th>
<td>1,330,122</td>
<td>5,676.16</td>
</tr>
<tr>
<th>高知</th>
<td>691,602</td>
<td>7,103.64</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>合計</th>
<td>3,695,619</td>
<td>18,803.33</td>
</tr>
</tfoot>
</table>
| 県名 | 人口 | 面積(km2) |
|---|---|---|
| 徳島 | 723,096 | 4,146.75 |
| 香川 | 950,799 | 1,876.78 |
| 愛媛 | 1,330,122 | 5,676.16 |
| 高知 | 691,602 | 7,103.64 |
| 合計 | 3,695,619 | 18,803.33 |
一般的なブラウザでは“th”要素の内容は太字で表示されます。
#
属性と値
| 属性 | 値 | ||
|---|---|---|---|
| 属性 | 説明 | 値 | 説明 |
| 必須属性 | |||
| なし | |||
| 任意属性 | |||
| グローバル属性 | |||
| colspan="" | セルが範囲とする列の数 | 正の整数 | セルが範囲とする列の数 |
| rowspan="" | セルが範囲とする行の数 | 正の整数 | セルが範囲とする行の数 |
| 0 | 行グループ内で後に続くすべての行 | ||
| headers="" | セルに関連付ける見出し | ID名 | 関連づける“th”要素の“id”属性の値 |
| scope="" | 見出しの対象範囲 | row | 同じ行のセル |
| col | 同じ列のセル | ||
| rowgroup | 同じ行グループ内のセル | ||
| colgroup | 同じ列グループ内のセル | ||
| auto | 自動判定 | ||
| abbr="" | セルの内容を音声ブラウザなどで参照した時の代替テキスト | テキスト | セルの内容を音声ブラウザなどで参照した時の代替テキスト |
過去に定義されていた属性
| 属性 | 値 | ||
|---|---|---|---|
| 属性 | 説明 | 値 | 説明 |
| axis="" |
セルの内容の分類名 | テキスト | セルの内容の分類名 |
| nowrap="" |
セル内のテキストを改行させない | nowrap | セル内のテキストを改行させない |
| width="" |
セルの横幅 | 正の整数 | 横幅のピクセル数 |
| 正の整数% | 横幅の表示領域に対する割合 | ||
| height="" |
セルの高さ | 正の整数 | 高さのピクセル数 |
| 正の整数% | 高さの表示領域に対する割合 | ||
| align="" |
セルの内容の水平方向の表示位置 | left | 左揃え |
| center | 中央揃え | ||
| right | 右揃え | ||
| justify | 両端揃え | ||
| char | “char”属性で指定した文字を揃える | ||
| char="" |
揃え文字の指定 | 文字 | 揃え文字 |
| charoff="" |
セルの端から揃え文字までの距離 | 正の整数 | セルの端から揃え文字までの距離のピクセル数 |
| 正の整数% | セルの端から揃え文字までの距離の表示領域に対する割合 | ||
| valign="" |
セルの内容の垂直方向の表示位置 | top | セルの上端に揃える |
| middle | セルの中央に揃える | ||
| bottom | セルの下端に揃える | ||
| baseline | 1行目をベースラインで揃える | ||
| bgcolor="" |
セルの背景色 | 色 | セルの背景色 |
| sorted="" |
表をソートした時の順序 | 正の整数 | 表をソートした時の順序 |
| 正の整数 reversed | 表をソートした時の順序 | ||
| reversed | 逆順でソート | ||
#
仕様書
“th”要素はHTML2.0の後に発行された“HTML Tables (RFC 1942)”から定義されている要素です。現行の仕様であるHTML Living Standardでも定義されています。
定義されている仕様書
![]() |
![]() |
![]() |
![]() |
![]() |
|
|---|---|---|---|---|---|
| <th> | ![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
DOMインターフェース
[Exposed=Window]
interface HTMLTableCellElement : HTMLElement {
[HTMLConstructor] constructor();
[CEReactions] attribute unsigned long colSpan;
[CEReactions] attribute unsigned long rowSpan;
[CEReactions] attribute DOMString headers;
readonly attribute long cellIndex;
[CEReactions] attribute DOMString scope; // only conforming for th elements
[CEReactions] attribute DOMString abbr; // only conforming for th elements
// also has obsolete members
};
UAスタイルシート
@namespace url(http://www.w3.org/1999/xhtml);
th {
unicode-bidi: isolate;
display: table-cell;
padding: 1px;
vertical-align: inherit;
}
table[rules=none i] > tr > th, table[rules=groups i] > tr > th, table[rules=rows i] > tr > th, table[rules=cols i] > tr > th, table[rules=all i] > tr > th, table[rules=none i] > thead > tr > th, table[rules=groups i] > thead > tr > th, table[rules=rows i] > thead > tr > th, table[rules=cols i] > thead > tr > th, table[rules=all i] > thead > tr > th, table[rules=none i] > tbody > tr > th, table[rules=groups i] > tbody > tr > th, table[rules=rows i] > tbody > tr > th, table[rules=cols i] > tbody > tr > th, table[rules=all i] > tbody > tr > th, table[rules=none i] > tfoot > tr > th, table[rules=groups i] > tfoot > tr > th, table[rules=rows i] > tfoot > tr > th, table[rules=cols i] > tfoot > tr > th, table[rules=all i] > tfoot > tr > th {
border-color: black;
}
/* 文書の文字エンコーディングが ISO-8859-8 である場合 */
th {
unicode-bidi: bidi-override;
}



Jun. 3rd,2015






























