我们如何在HTML中包括表格列的属性?
使用<col>标记包括表列的属性。HTML<col>标记允许作者将表列的属性规范分组在一起。它不会在结构上将列分组在一起-这就是<colgroup>元素的作用。
以下是属性-
left
center
justify
char
定义水平对齐,Html5不支持。
定义用于对齐文本的字符(与align=“char”一起使用),Html5不支持该字符。
指定相对于使用char属性指定的第一个字符的对齐偏移量(以像素或百分比值为单位),Html5不支持该偏移量
定义<col>应该跨越的列数,Html5不支持。
middle
top
baseline
定义垂直对齐,Html5不支持。
为当前col元素跨出的每一列指定默认宽度,Html5中不支持。
示例
您可以尝试运行以下代码以实现<col>标记-
<!DOCTYPE html>
<html>
<head>
<title>HTML col Tag</title>
</head>
<body>
<p>This example shows a colgroup that has three columns of different widths:</p>
<table border = "1">
<colgroup span = "4">
<col width = "40"></col>
<col width = "70"></col>
<col width = "100"></col>
<col width = "130"></col>
<col width = "160"></col>
</colgroup>
<tr>
<td>One</td>
<td>Two</td>
<td>Three</td>
<td>Four</td>
<td>Five</td>
</tr>
</table>
</body>
</html>