HTML colgroup width attribute
Examples
It provides a predefined width of the first column is 200 pixels <colgroup> element:
<table border="1">
<colgroup width="200">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>
<colgroup width="200">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>
try it"
Browser Support
All major browsers support width attribute. However, no browser supportsrelative_lengthvalue.
Definition and Usage
In HTML5 does not support <colgroup> width attribute.
Width attribute specifies the width of the column group.
Typically, column groups, the space occupied by the contents of display space that it needs. width property is used for the column groups set up predefined width.
Note: This property will be set to any width covering <col> element.
grammar
<colgroup width="pixels|%|relative_lngth">
Property Value
值 | 描述 |
---|---|
pixels | 设置以像素计的宽度值(例子:width="50")。 |
% | 设置以包围元素的百分比计的宽度值(例子:width="50%")。 |
relative_length | 把可用像素分配到各部分。部分一设置为 "1*",部分二设置为 "2*"。(例如,表格的宽度是 100px,第一个列组是 20px,第二个列组是 50%,那么剩余的可用像素是 30px。)
例子:如果可用像素是 30px,那么可以设置部分一为 "1*",部分二为 "2*",这将被解释为 10 和 20 像素("1*" 为部分一,"2*" 为部分二)。 |
HTML <colgroup> tag