<colgroup> 要素は、親の<table> 要素内の1つ以上の縦列のグループを表します。内容に<col> 要素が含まれていない場合は、代わりにspan 属性でグループを指定します。span 属性の値は0より大きい整数でなければなりません。
- カテゴリー
- なし
- 配置場所
<table> 要素の子要素として、<caption> 要素よりも後、<thead> 要素、<tbody> 要素、<tfoot> 要素、<tr> 要素よりも前に配置。- 内容
span 属性がある場合はなし(空要素)。span 属性がない場合は0個以上の<col> 要素と<template> 要素。- 属性
-
span="縦列の数(整数)"- 内容に
<col> 要素を含まない場合のみ、グループ化する縦列の数を0より大きい整数で指定します。 - グローバル属性
accesskey,autocapitalize,autofocus,class,contenteditable,data-*,dir,draggable,enterkeyhint,hidden,id,inputmode,is,itemid,itemprop,itemref,itemscope,itemtype,lang,nonce,spellcheck,style,tabindex,title,translate
サンプル
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8" />
<title>HTML5 › colgroup</title>
<style>
table { border-collapse: collapse; }
th, td { padding: .5em; border: #ccc 1px solid; }
.name { background: #eef; }
.sex-age { background: #fee; }
</style>
</head>
<body>
<h1>HTML5 › colgroup</h1>
<table>
<caption>入居者一覧</caption>
<colgroup span="1" class="name"></colgroup>
<colgroup span="2" class="sex-age"></colgroup>
<thead>
<tr><th>名前</th><th>性別</th><th>年齢</th></tr>
</thead>
<tbody>
<tr><th>やまだ いちろう</th><td>男</td><td>96</td></tr>
<tr><th>さとう じろう</th><td>男</td><td>78</td></tr>
<tr><th>すずき さくら</th><td>女</td><td>84</td></tr>
</tbody>
</table>
</body>
</html>
