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

HTML col标签

本文概述

HTML <col>标记用于为HTML表中<colgroup>元素内的每一列指定公共列属性。

<col>标签在需要为每个列单元格应用通用样式规则而不是单独应用时很有用。

句法

<col span=" "   style=" ">

注意:在HTML中, <col>标记不需要结束标记, 但是在XHTML中, 它需要结束标记</ col>标记。

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

Display Inline
开始日期/结束日期 Start tag(Empty tag)
Usage HTML tables

例子1

<!DOCTYPE html>
<html>
<head>
	<title>Col tag</title>
</head>
<body>
<h2>Example of Col Tag</h2>
<table border="1">
	<colgroup>
		<col  span="2" style="background-color: #7fffd4">
		<col span="2" style="background-color: 	#98f5ff">
	</colgroup>
	<tr>
		<th>Roll No.</th>
		<th>Name</th>
		<th>Maths</th>
		<th>Science</th>
	</tr>
	<tr>
		<td>1</td>
		<td>Avinash</td>
		 <td>68</td>
		 <td>54</td>
	</tr>
	<tr>
		<td>2</td>
		<td>Neha</td>
		 <td>65</td>
		 <td>61</td>
	</tr>
	<tr>
		<td>3</td>
		<td>Jenny</td>
		 <td>55</td>
		 <td>78</td>
	</tr>
	<tr>
		<td>4</td>
		<td>Vivek</td>
		 <td>75</td>
		 <td>52</td>
	</tr>
</table>
</body>
</html>

立即测试

输出:

HTML col标签

属性

特定于标签的属性

element should contain. The default value of span attribute is 1.
属性 描述
align 左居中右对齐 它指定每个列单元格的水平对齐方式。 (HTML5不支持)。
char character 它根据列中的字符指定内容的对齐方式。如果align未设置为char, 它将被忽略。 (HTML5不支持)。
charoff number 它设置字符数, 以使列数据偏离char属性指定的对齐字符。 (HTML5不支持)。
span number 它指定一个
valign 上中下基线 它指定列的垂直对齐方式。 (HTML5不支持)。
width %像素relative_length 它指定列的宽度。 (HTML5不支持)。

全局属性

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

事件属性

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

支持的浏览器

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

评论 抢沙发

评论前必须登录!