Javascript Reference - HTML DOM ColumnGroup Object

The ColumnGroup class represents an HTML <colgroup> element.

ColumnGroup Object Properties

Property Description
span Sets or gets the span attribute for a column group

Standard Properties and Events

The ColumnGroup object supports the standard properties and events.


The following code shows how to get <colgroup> element by using getElementById().

<!DOCTYPE html>
  <colgroup id="myColgroup" span="2" style="background:red"></colgroup>
  </tr><!--   w  ww.ja  v  a  2  s  .c  o m-->
<button onclick="myFunction()">test</button>
<p id="demo"></p>
function myFunction() {
    var x = document.getElementById("myColgroup").span;
    document.getElementById("demo").innerHTML = x;


The code above is rendered as follows: