X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

TableData colSpan Property

TableData Object Reference TableData Object

Example

Change the number of columns a table cell should span:

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

Try it yourself »


Definition and Usage

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

The colspan attribute specifies the number of columns a table cell should span.

Tip: Use the rowSpan property to set or return the value of the rowspan attribute.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The colSpan property is supported in all major browsers.


Syntax

Return the colSpan property:

tabledataObject.colSpan

Set the colSpan property:

tabledataObject.colSpan=number

Property Values

Value Description
number Specifies the number of columns a cell should span

Technical Details

Return Value: A Number, representing the number of columns a table cell should span


More Examples

Example

Return the number of columns a specific table cell should span:

var x = document.getElementById("myTd").colSpan;
document.getElementById("demo").innerHTML = x;

The result of x will be:

2

Try it yourself »


Related Pages

HTML reference: HTML <td> colspan attribute


TableData Object Reference TableData Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook