TableData colSpan attribute

Definition and usage

colSpan Attribute sets or returns the value of the colspan attribute.

<td> colspan attribute Specify the number of columns the table cell should span.

Tip:Use rowSpan attribute Set or return HTML rowspan attribute value.

See also:

HTML Reference Manual:HTML <td> Tag

Example

Example 1

Change the number of columns the table cell should span:

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

Try it yourself

Example 2

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

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

Try it yourself

Syntax

Return colSpan attribute:

tabledataObject.colSpan

Set colSpan attribute:

tabledataObject.colSpan = number

Attribute Value

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

Technical Details

Return Value: Number, indicating the number of columns the table cell 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 <td> colspan Attribute