个性化阅读
专注于IT技术分析

HTML colgroup标记

本文概述

HTML <colgroup>标记指定HTML表中的列组。它是一个或多个<col>元素的父容器, 用于在HTML表中应用不同的属性。

注意:<colgroup>标签必须与<caption>之后, <thead>或<tbody>元素之前的<table>元素一起使用。

句法

<colgroup>......</colgroup>

以下是有关HTML <colgroup>标记的一些规范

Display None
开始日期/结束日期 开始标签和结束标签
Usage HTML表格

<!DOCTYPE html>
<html>
<head>
	<title>Colgroup tag</title>
</head>
<body>
<h2>Example of Colgroup Tag</h2>
<table border="1">
	<colgroup>
		<col  style="background-color: green" width="40">
		<col span="2" style="background-color:	#ff7256" width="80">
	</colgroup>
	<tr>
		<th>Sr.No</th>
		<th>Product</th>
		<th>Price</th>
	</tr>
	<tr>
		<td>1</td>
		<td>Rice</td>
		 <td>85</td>
	</tr>
	<tr>
		<td>2</td>
		<td>Butter</td>
		 <td>260</td>	
	   </tr>
	<tr>
		<td>3</td>
		<td>Mango</td>
		 <td>125</td>
	</tr>
</table>
</body>
</html>

立即测试

输出:

HTML colgroup标签

属性

属性 描述
align 左居中右对齐 它指定列内容的对齐方式。 (HTML5不支持)。
char character 它指定列组中的内容与字符的对齐方式。 (HTML5不支持)。
charoff number 它设置字符数, 以使列数据偏离char属性指定的对齐字符。 (HTML5不支持)。
span number 它指定colgroup应该跨越的列数。
valign 上中下基线 它指定列组的垂直对齐方式。 (HTML5不支持)。
width %像素relative_length 它指定列组的宽度。 (HTML5不支持)。

全局属性

HTML <colgroup>标记支持HTML中的所有全局属性。

事件属性

HTML <colgroup>标记支持HTML中的所有事件属性。

支持的浏览器

Element Chrome IE Firefox Opera Safari
<colgroup> Yes Yes Yes Yes Yes
赞(0)
未经允许不得转载:srcmini » HTML colgroup标记

评论 抢沙发

评论前必须登录!