ColumnGroup span attribute

Definition and usage

span Set or return the value of the span attribute of the column group.

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

Tip:To span the number of columns of the <colgroup> element, <colgroup> Different attributes of the columns, please use Column object

See also:

HTML 参考手册:HTML <colgroup> ਟੈਗ

Instance

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 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 规定

技术细节

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

浏览器支持

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

相关页面

HTML 参考手册:HTML <colgroup> span ਪ੍ਰਤੀਰੂਪ