Skip to content
Related Articles

Related Articles

How to define the number of columns a cell should span using HTML5 ?

View Discussion
Improve Article
Save Article
  • Last Updated : 28 Oct, 2020

This article will show you how a column can be made to span over multiple cells. This is done using the colspan attribute when using the <td> tag. This allows the single table cell to span the width of more than one cell or column. It provides similar functionality to the “merge cell” functions in spreadsheet programs like Excel.


<td colspan = "value">table content...</td>


<!DOCTYPE html>
        body {
            text-align: center;
        h1 {
            color: green;
        td {
            border: 1px solid black;
            border-collapse: collapse;
        How to define the number of
        columns a cell should span
        using HTML5?
        <!-- The <tr> tag starts here -->
            <th>User ID</th>
        <!-- The last row -->
            <!-- This td will span two 
                columns, that is a single 
                column will take up the 
                space of 2 -->
            <td colspan="2">
                Sumit: 6574


Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!