|
|
The The Note: The Tip: To define different properties to a column within a |
<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>
</table>
| Attribute | Value | Description |
|---|---|---|
| span | number | Specifies the number of columns a column group should span |
<style>
table, th, td {
border: 1px solid black;
}
colgroup {
display: table-column-group;
}
</style>
Set the background color of the first two columns using the <colgroup> span attribute:
The span attribute defines the number of columns a <colgroup> element should span.
Tip: To define different properties to a column within a <colgroup>, use the <col> tag within the <colgroup> tag.

<colgroup span="number">
| Value | Description |
|---|---|
| number | Sets the number of columns a column group should span |
<!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>
Category: | Web Tutorial |
Sub Category: | HTML Tag |
Uploaded by: | Admin |
Read Articlehttps://develop.horje.com/learn/1434/reference