Die thead-tag

Die tag thead spesifiseer die boonste gedeelte van 'n tabel. Word gebruik om rye op so 'n manier te groepeer dat CSS-style dadelik op 'n sekere groep toegepas kan word. Daar kan slegs een thead tag in een tabel wees.

Die tag thead word dikwels saam gebruik met tbody en tfoot om die boonste gedeelte, hoofgedeelte en onderste gedeelte van 'n HTML-tabel te spesifiseer.

Voorbeeld

Kom ons voeg 'n rooi tekskleur by aan die groep rye wat deur die thead tag gegroepeer is, met behulp van die eienskap color:

html<table>
  <thead>
    <tr>
      <th>Naam</th>
      <th>Van</th>
      <th>Salaris</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>naam1</td>
      <td>van1</td>
      <td>200$</td>
    </tr>
    <tr>
      <td>naam2</td>
      <td>van2</td>
      <td>1000$</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td>telling: 2</td>
      <td>-</td>
      <td>totaal: 1200$</td>
    </tr>
  </tfoot>
</table>
cssthead {
  color: red;
}

table, td, th {
  border: 1px solid black;
}

Результат:

Voorbeeld

En hier staan thead nie bo nie, en tfoot nie onder nie, nietemin sal die blaaier hulle op hul regte plekke plaas:

html<table>
  <tfoot>
    <tr>
      <td>telling: 2</td>
      <td>-</td>
      <td>totaal: 1200$</td>
    </tr>
  </tfoot>
  <tbody>
    <tr>
      <td>naam1</td>
      <td>van1</td>
      <td>200$</td>
    </tr>
    <tr>
      <td>naam2</td>
      <td>van2</td>
      <td>1000$</td>
    </tr>
  </tbody>
  <thead>
    <tr>
      <th>Naam</th>
      <th>Van</th>
      <th>Salaris</th>
    </tr>
  </thead>
</table>
csstable, td, th {
  border: 1px solid black;
}

Результат:

Sien ook

  • die tags tbody, tfoot,
    wat tabelrye groepeer
  • die tag caption,
    wat die opskrif vir die hele tabel spesifiseer
  • die eienskappe rowspan en colspan,
    wat tabelrye en -kolomme saamsmelt