化拓教育网
您的当前位置:首页htmlcolgroup标签怎么用

htmlcolgroup标签怎么用

来源:化拓教育网
 html colgroup标签用于对表格中的列进行组合,以便对其进行格式化,<colgroup>标签只能在table元素中使用。

colgroup标签是什么意思?html colgroup标签怎么用

作用:对表格中的列进行组合,以便对其进行格式化。

说明:

如需对全部列应用样式,<colgroup> 标签很有用,这样就不需要对各个单元和各行重复应用样式了。<colgroup> 标签只能在 table 元素中使用。

注释:

所有主流浏览器都支持 <colgroup> 标签。Firefox、Chrome 以及 Safari 仅支持 colgroup 元素的 span 和 width 属性。

html colgroup标签使用示例

<!DOCTYPE html>
<html>
<head>
 <meta charset="UTF-8">
 <title>Title</title>
</head>
<body>
<table width="100%" border="1">
 <colgroup span="2"></colgroup>
 <colgroup style="color:#0000FF;"></colgroup>
 <tr>
 <th>商品种类</th>
 <th>名称</th>
 <th>价格</th>
 </tr>
 <tr>
 <td>衣服</td>
 <td>衬衣</td>
 <td>53元</td>
 </tr>
 <tr>
 <td>鞋子</td>
 <td>板鞋</td>
 <td>199元</td>
 </tr>
</table>
</body>
</html>

效果:

显示全文