ColumnGroup span attribute

Definition and usage

span Sets or returns the value of the span attribute of the column group.

<colgroup> span attribute Define the number of columns that the <colgroup> element should span.

Tip:To span the columns of <colgroup> To specify different attributes for columns, use Column object.

See also:

HTML 参考手册:HTML <colgroup> 标签

Example

Example 1

Set the background color of the first two columns to red:

document.getElementById("myColgroup").span = "2";
document.getElementById("myColgroup").style.backgroundColor = "red";

Try it yourself

Example 2

Return the number of columns that the <colgroup> element should span:

var x = document.getElementById("myColgroup").span;

Try it yourself

Syntax

Return span attribute:

columngroupObject.span

Set formMethod attribute:

columngroupObject.span = number

属性值

描述
number 规定 <colgroup> 元素应跨越的列数。

技术细节

返回值: 规定 <colgroup> 元素应跨越的列数。

浏览器支持

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 支持 支持 支持 支持

相关页面

HTML 参考手册:HTML <colgroup> span 属性