HTML colspan attribute

colspan attribute allows a cell to contain or span more than one columns. In other words, two or more cells are merged and the resulting cell contains spans two or more columns.

Example

Usage Stats of Browsers
Browsers Months(2017)
January February
Chrome 62.07% 62.97%
Firefox 14.87% 14.83%
Try </>

In the above example, a cell contains two columns because we have used 2 value of colspan attribute.

colspan attribute values

The value of colspan attribute is a valid positive integer. And this integer is the number of columns spanned by the cell.

Example

Usage Stats of Browsers
Browsers Months(2017)
January February March
Chrome 62.07% 62.97% 62.80%
Firefox 14.87% 14.83% 14.99%
Try </>

The above example contains one empty cell. rowspan attribute merges the empty cell with other cells.

3 value indicates that cell contains three columns.

Example

Usage Stats of Browsers
Browsers Months(2017)
January February March
Chrome 62.07% 62.97% 62.80%
Firefox 14.87% 14.83% 14.99%
Try </>

2 value of rowspan attribute allows a cell to contain two rows i.e. it merges two cells.

Related Tags

The tags that support this attribute are as follows.

<th> tag

<th> tag defines a cell of data in the heading section of the table. It supports the colspan attribute.

<td> tag

<td> tag defines a cell of data in the body section of the table. colspan attribute is applicable on the <td> tag



Was this article helpful?

 

Email:

Message:

Get the newsletter