Related Articles

Related Articles

HTML | span Attribute
  • Last Updated : 12 Jul, 2019

The HTML span Attribute is used to define the number of column that a <col>, <colgroup> element should span.

Applicable:

  • col
  • colgroup

Syntax:

< element span="number"> 

Example 1: This example illustrates the use of span attribute in col Element.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML col span Attribute
    </title>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
  
    <h2>HTML col span Attribute</h2>
  
    <table border="1">
        <colgroup>
            <col span="2" 
                 style="background-color:green">
                <col style="background-color:blue">
        </colgroup>
        <tr>
            <th>Name</th>
            <th>Branch</th>
            <th>Expenses</th>
        </tr>
  
        <tr>
            <td>BITTU</td>
            <td>CSE</td>
            <td>2500.00</td>
        </tr>
  
        <tr>
            <td>RAKESH</td>
            <td>ECE</td>
            <td>1400.00</td>
        </tr>
    </table>
</body>
  
</html>

chevron_right


Output:



Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML ColumnGroup span Attribute
    </title>
  
    <style>
        #myColGroup {
            background: green;
        }
          
        table {
            color: white;
            margin-left: 180px;
            background: yellow;
        }
          
        #Geek_p {
            color: green;
            font-size: 30px;
        }
          
        td {
            padding: 10px;
        }
    </style>
</head>
  
<body style="text-align:center;">
  
    <h1 style="color:green;"
            GeeksForGeeks 
        </h1>
  
    <h2>HTML ColumnGroup span Attribute</h2>
  
    <table>
        <colgroup id="myColGroup" 
                  span="2">
      </colgroup>
        <tr>
            <th>S.No</th>
            <th>Title</th>
            <th>Geek_id</th>
        </tr>
        <tr>
            <td>Geek_1</td>
            <td>GeekForGeeks</td>
            <th>Geek_id_1</th>
        </tr>
        <tr>
            <td>Geek_2</td>
            <td>GeeksForGeeks</td>
            <th>Geek_id_2</th>
        </tr>
    </table>
</body>
  
</html>

chevron_right


Output

Supported Browsers: The browsers supported by HTML span Attribute are listed below:

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

full-stack-img




My Personal Notes arrow_drop_up
Recommended Articles
Page :