Horje
HTML span Attribute

Definition and Usage

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


Applies to

The span attribute can be used on the following elements:

Elements Attribute
<col> span
<colgroup> span

Browser Support

The span attribute has the following browser support for each element:


How to add the first two columns should have a background color of red - HTML span Attribute

Col Example. The col element.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
}
</style>
</head>
<body>

<h1>The col element</h1>

<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>

</body>
</html>

Output should be:

How to add the first two columns should have a background color of red - HTML span Attribute

How to Set the background color of the first two columns using the <colgroup> span attribute - HTML span Attribute

Colgroup Example. The colgroup span attribute.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
}
</style>
</head>
<body>

<h1>The colgroup span attribute</h1>

<table>
  <colgroup span="2" style="background:red"></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>

</body>
</html>

Output should be:

How to Set the background color of the first two columns using the <colgroup> span attribute - HTML span Attribute




html span attribute

Type:
Develop
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded by:
Admin


Read Article
https://develop.horje.com/learn/1434/reference