Atrybut zakresu HTML


Definicja i użycie

spanAtrybut określa liczbę kolumn , które powinien obejmować element <col>lub .<colgroup>


Dotyczy

Atrybutu spanmożna użyć na następujących elementach:

Elementy Atrybut
<kol> Zakres
<grupa kol> Zakres

Przykłady

Kol Przykład

Tutaj pierwsze dwie kolumny powinny mieć tło w kolorze czerwonym:

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

Przykład grupy Colgroup

Ustaw kolor tła pierwszych dwóch kolumn za pomocą atrybutu span <grupa kol>:

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

Obsługa przeglądarki

spanAtrybut ma następującą obsługę przeglądarki dla każdego elementu :

Element
col Yes Yes Yes Yes Yes
colgroup Yes Yes Yes Yes Yes