Horje

How to add HTML <col> span Attribute

Here, the first two columns should have a background color of red.

Definition and Usage

The span attribute defines the number of columns a <col> element should span.


Browser Support

Syntax

<col span="number">

Attribute Values

Value Description
number Sets the number of columns a <col> element should span
index.html
Example: HTML
<table>
  <colgroup>
    <col span="2" style="background-color:red">
    <col style="background-color:yellow">
  </colgroup>
  <tr>
    <th>ISBN</th>
    <th>Title</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>3476896</td>
    <td>My first HTML</td>
    <td>$53</td>
  </tr>
  <tr>
    <td>5869207</td>
    <td>My first CSS</td>
    <td>$49</td>
  </tr>
</table>

Output should be:

How to add HTML <col> span Attribute




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Tag
Uploaded by:
Admin