<colgroup> 标签用于对表格中的列进行组合,以便对其进行格式化。
如需对全部列应用样式,<colgroup> 标签很有用,这样就不需要对各个单元和各行重复应用样式了。
<colgroup> 标签只能在 table 元素中使用。
定义和用法
<colgroup> 标签定义表格列的组。通过此标签,您可以对列进行组合,以便格式化。该元素只有在 <table> 中才是合法的。
HTML 4.01 与 HTML 5 之间的差异
4.01 中的大多数属性都不再得到支持。
提示和注释
注释:colgroup 元素只能包含 col 元素。
注释:colgroup 元素无法创建表格列。如需创建列,必须在 tr 元素内规定 td 元素。
提示:如果需要向一个列组规定相同的属性值,请使用该元素。
提示:如果需要为一个或多个列规定属性值,请使用 col 元素。
例子:
<table> <colgroup span="3" style="color:blue"></colgroup>
<tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> </tr> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> </tr> </table>
属性
属性 | 值 | 描述 | 4 | 5 |
---|---|---|---|---|
align |
|
定义列中的单元格内容的水平对齐方式。 | 4 | |
char | character | 定义一个字符,按照该字符对齐文本。 | 4 | |
charoff |
|
规定第一个对齐字符的偏移量。 | 4 | |
span | number | 定义 <colgroup> 应当横跨的列数。 | 4 | 5 |
valign |
|
定义列中的单元格内容的垂直对齐方式。 | 4 | |
width |
|
定义列的宽度。 | 4 | |
标准属性
class, contenteditable, contextmenu, dir, draggable, id, irrelevant, lang, ref, registrationmark, tabindex, template, title
如需完整的描述,请访 HTML 5 中标准属性。
事件属性
onabort, onbeforeunload, onblur, onchange, onclick, oncontextmenu, ondblclick, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onerror, onfocus, onkeydown, onkeypress, onkeyup, onload, onmessage, onmousedown, onmousemove, onmouseover, onmouseout, onmouseup, onmousewheel, onresize, onscroll, onselect, onsubmit, onunload
如需完整的描述,请访 HTML 5 中事件属性。
<html>
<body>
<table width="100%" border="1">
<colgroup span="2" align="left"></colgroup>
<colgroup align="right" style="color:#0000FF;"></colgroup>
<tr>
<th>ISBN</th>
<th>Title</th>
<th>Price</th>
</tr>
<tr>
<td>3476896</td>
<td>My first HTML</td>
<td>$53</td>
</tr>
<tr>
<td>2489604</td>
<td>My first CSS</td>
<td>$47</td>
</tr>
</table>
</body>
</html>
推荐阅读
<!-- CSS goes in the document HEAD or added to your external stylesheet --><style type="text/css">table.hovertable { font-family: verdana,arial,sans-serif; font-size:11px; color:#333333; border-width>>>详细阅读
本文标题:
地址:http://www.17bianji.com/kaifa2/CSS/34345.html
1/2 1