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 that the <colgroup> element should span.

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

See also:

HTML Reference Manual:HTML <colgroup> Tag

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 the span attribute of:

columngroupObject.span

Set the formMethod attribute:

columngroupObject.span = number

Attribute Value

Value Description
number Specifies the number of columns the <colgroup> element should span.

Technical Details

Return Value: Specifies the number of columns the <colgroup> element should span.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support

Related Pages

HTML Reference Manual:HTML <colgroup> span Attribute