Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM TableHeader colSpan property

TableHeader colSpan property

TableHeader Object Reference The TableHeader object

Example

Change the number of columns a cell spans:

document.getElementById("myTh").colSpan="1";

Try it »


Definition and Usage

The colSpan property sets or returns the value of the colspan property.

The colspan property specifies the number of columns a table cell can span.

**Tip:** Use rowSpan Property used to set or return the value of the rowspan property.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the colSpan property.


Syntax

Return the colSpan property:

tableheaderObject

.colSpan

Set the colSpan property:

tableheaderObject

.colSpan=

number

Attribute values

Value Description
number Specifies the number of columns a cell can span.

Technical Details

Return Value: Number, representing the number of columns a table cell can span.

More examples

Example

Return the number of columns a specified table cell can span:

var x = document.getElementById("myTh").colSpan;

document.getElementById("demo").innerHTML=x;

x The output is:

2

Try it »


Related Articles

HTML Reference Manual:HTML colspan property


TableHeader Object Reference The TableHeader object