HTML <colgroup> tag
Examples
<Colgroup> and <col> tag for the three columns in the table set the background color:
<colgroup>
<col span="2" style="background-color:red">
<col style="background-color:yellow">
</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>
</table>
try it"
Browser Support
All major browsers support <colgroup> tag.
Tag definitions and instructions
<Colgroup> tag is used to form the columns in combination, in order to format it.
By using the <colgroup> tag, you can apply a style to an entire column, rather than requiring repeated for each cell in each row or set the style.
Note: Only in the <table> element of, after any <caption> element at any one <thead>, <tbody>, <tfoot>, before <tr> element uses <colgroup> tag.
Tip: If you want to <colgroup> in a column to define different properties, use within <colgroup> tag <col> tag.
Differences between HTML 4.01 and HTML5
HTML5 no longer supported in HTML 4.01 in most of the properties.
Attributes
属性 | 值 | 描述 |
---|---|---|
align | left right center justify char |
HTML5 不支持。规定在列组合中内容的水平对齐方式。 |
char | character | HTML5 不支持。规定根据哪个字符来对齐列组中的内容。 |
charoff | number | HTML5 不支持。规定第一个对齐字符的偏移量。 |
span | number | 规定列组应该横跨的列数。 |
valign | top middle bottom baseline |
HTML5 不支持。定义在列组合中内容的垂直对齐方式。 |
width | pixels % relative_length |
HTML5 不支持。规定列组合的宽度。 |
Global Properties
<colgroup> tag supports HTML global properties .
Event Properties
<colgroup> tag supports HTML event properties .