col span Attribute - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:col

Description

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

Attribute Values

Value Description
number Sets the number of columns a <col> element should span

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

Demo Code

ResultView the demo in separate window

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

<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>3</td>
    <td>My first HTML</td>
    <td>$2</td>
  </tr>
  <tr>
    <td>5</td>
    <td>My first CSS</td>
    <td>$1</td>
  </tr>
</table>

</body>
</html>

Related Tutorials