HTML and col.gt. tags
The label is used to set property values for one or more columns in a table.
Labels can only be used internally for the elements of the .lt;table and the elements of the .lt;colgroup.
The labels set the background color for the three columns in the table:
<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 out . . .
Browser support
All major browsers support the hashtag.
Label definition and instructions for use
The label specifies the column properties of each column within the element.
By using the label, you can apply styles to the entire column without having to repeatedly style each cell or row.
Note: The col element is an empty element that contains only properties. To create a column, you must specify the td element inside the tr element.
The difference between HTML 4.01 and HTML5
Most of the properties in HTML 4.01 are no longer supported in HTML5.
The difference between HTML and XHTML
In HTML, the label does not end the label.
In XHTML, the label must be properly turned off.
Property
属性 | 值 | 描述 |
---|---|---|
align |
left
right center justify char |
HTML5 不支持。 规定与 <col> 元素相关的内容的水平对齐方式。 |
char | character | HTML5 不支持。 规定根据哪个字符来对齐与 <col> 元素相关的内容。 |
charoff | number | HTML5 不支持。 规定第一个对齐字符的偏移量。 |
span | number | 规定 <col> 元素应该横跨的列数。 |
valign |
top
middle bottom baseline |
HTML5 不支持。 规定与 <col> 元素相关的内容的垂直对齐方式。 |
width |
%
pixels relative_length |
HTML5 不支持。 Specifies the width of a <col> element |
Global properties
Labels support the global properties of HTML.
The event property
The tag supports the event properties of HTML.