English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML参考手册

HTML标签大全

HTML: <colgroup> span属性

本文介绍HTML colgroup span属性的使用方法,在线实例演示如何使用HTML colgroup span属性、浏览器的兼容性、语法定义及其属性值详细资料等。

 HTML <colgroup> tag

在线示例

使用<colgroup> span属性设置前两列的背景色:

!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML <colgroup> span 属性使用-基础教程(oldtoolbag.com)</title>
<style>table, th, td {  border: 1px solid black;}</style>
</head>
<body>
<table>
  <colgroup span="2" style="background:red"></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>
  <tr>
    <td>5869207</td>
    <td>My first CSS</td>
    <td>$49</td>
  </tr>
</table>
</body>
</html>
Test and see ‹/›

Browser compatibility

IEFirefoxOperaChromeSafari

All major browsers support the span attribute.

Definition and usage

The span attribute defines the number of columns the <colgroup> element should span.

Tip:To define different attributes for the columns within <colgroup>, use <col> tags.

HTML 4.01 with HTML5differences

None.

Syntax

<colgroup span="number">

Attribute value

ValueDescription
numberSet the number of columns that should span.
 HTML <colgroup> tag