HTML span attribute

The span attribute allows an element to span more than columns for stylish purposes. span attribute can style one or more columns instead of cells one by one.

<table border="5">
 <colgroup>
  <col bgcolor="lightgreen" span="2"></col>
  <col bgcolor="lightgray"></col>
 </colgroup>
 <tr>
  <th> Countries</th>
  <th> Population</th>
  <th> Area</th>
  <th> Capital</th>
 </tr>
		
 <tr>
  <td> China</td>
  <td> 7,432,663,275</td>
  <td> 9,572,900</td>
  <td> Beijing</td>
 </tr>
  
 <tr>
  <td> India</td>
  <td> 1,382,323,332</td>
  <td> 3,287,263</td>
  <td> New Delhi</td>
 </tr>		
</table>
</>
Countries Population Area Capital
China 7,432,663,275 9,572,900 Beijing
India 1,382,323,332 3,287,263 New Delhi

Attribute values

All possible values of span attribute

The value of span attribute is a valid positive integer.

Related Tags

The tags that support span attribute

<col> tag

col element represents a column in a table. It takes part in making the structure of table. col tag is used as the child of the colgroup element.

<colgroup> tag

colgroup is used to group the columns. span attribute is applicable on the colgroup element.



Was this article helpful?