colgroup span Attribute - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:colgroup

Description

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

Attribute Values

Value Description
number Sets the number of columns a column group should span

The following code shows how to Set the background color of the first two columns using the <colgroup> span attribute:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
    border: 1px solid black;
}
</style><!--from   w  ww.  java  2 s  . c  o m-->
</head>
<body>

<table>
  <colgroup span="2" style="background:red"></colgroup>
  <tr>
    <th>ISBN</th>
    <th>Title</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>1</td>
    <td>My first HTML</td>
    <td>$1</td>
  </tr>
  <tr>
    <td>2</td>
    <td>My first CSS</td>
    <td>$2</td>
  </tr>
</table>

</body>
</html>

Related Tutorials