HTML <colgroup> span eigenschap

Definitie en gebruik

span Definitie van <colgroup> element dat het aantal kolommen overschrijdt.

Tip:If you need to define different attributes for a specific column within <colgroup>, use <col> tag.

Example

Set the background color of the first two columns using the span attribute of <colgroup>:

<table>
  <colgroup span="2" style="background:#B0C4DE"></colgroup>
  <tr>
    <th>ISBN</th>
    <th>Title</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>3476896</td>
    <td>HTML入门</td>
    <td>$53</td>
  </tr>
  <tr>
    <td>5869207</td>
    <td>CSS入门</td>
    <td>$49</td>
  </tr>
</table>

Try it yourself

Syntax

<colgroup span="number">

Attribute value

Value Description
number Set the number of columns to span for the column group.

Browser support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support