Baza znanjaIzpitno središče
SLSlovenščina
Izberi jezik13

CKTIS / HTML

koncept HTML: tables

Tabele HTML opisujejo podatke, katerih pomen izhaja iz presečišč vrstic in stolpcev, ne le iz vidne poravnave.

Različica: WHATWG HTML Living Standard; index snapshot date recorded separately

Sintaksa

<table><caption>…</caption><thead>…</thead><tbody>…</tbody></table>

table vsebuje izbirni caption, skupine thead, tbody, tfoot in vrstice tr s celicami th ali td; vrstni red in kontekst sledita modelom.

rowspan je lahko rowspan="0" in zajame preostale vrstice skupine; drugi razponi in colspan so pozitivni, celice pa se ne smejo prekrivati.

Preproste glave uporabljajo scope z row ali col; zapletene tabele povežejo headers z id. Tabela ni za postavitev strani.

Primer prebere caption, zbirki rows in tBodies, cellIndex ter izrecna headers in scope.

Primeri

<!doctype html>
<meta charset="utf-8">
<table id="prices">
  <caption>Prices</caption>
  <thead><tr><th id="product" scope="col">Product</th><th id="amount" scope="col">Amount</th></tr></thead>
  <tbody><tr><th id="widget" scope="row">Widget</th><td id="price" headers="widget amount">9</td></tr></tbody>
</table>
<output id="result"></output>
<script>
const table = document.querySelector("#prices");
const cell = document.querySelector("#price");
result.textContent = `caption=${table.caption.textContent}; rows=${table.rows.length}; bodies=${table.tBodies.length}; cellIndex=${cell.cellIndex}; headers=${cell.headers}; rowScope=${widget.scope}`;
</script>

Rezultat

caption=Prices; rows=2; bodies=1; cellIndex=1; headers=widget amount; rowScope=row

Rezultat potrdi mrežo DOM in avtorske povezave; ne simulira bralnika zaslona ali zapletenega algoritma glav.

Viri