TableHeader colSpan attribute

Definition and usage

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

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

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

See also:

HTML 参考手册:HTML <th> 标签

Example

Example 1

Change the number of columns the cell should span:

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

Try it yourself

Example 2

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

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

Try it yourself

Syntax

Return colSpan attribute:

tableheaderObject.colSpan

Set colSpan attribute:

tableheaderObject.colSpan = number

属性值

描述
number 规定单元格应跨越的列数。

技术细节

返回值: 数值,表示表格单元格应跨越的列数。

浏览器支持

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 支持 支持 支持 支持

相关页面

HTML 参考手册:HTML <th> colspan 属性