Intern
Milline on HTML-i tabeli struktuur?
sobes.tech AI
Vastus AI-lt
HTML-tabeli struktuūra tiek noteikta ar vairākām elementiem:
<table>: Tabeles ietvars.<caption>: Neobligāts virsraksts tabulai.<colgroup>un<col>: Neobligāti elementi kolonu grupēšanai un stilu piemērošanai.<thead>: Sadaļa ar kolonu virsrakstiem.<tbody>: Galvenā satura sadaļa.<tfoot>: Apakšsadaļa ar tabulas kājeni.<tr>: Tabeles rinda.<th>: Virsraksta šūna rindā.<td>: Datu šūna rindā.
Elementi <thead>, <tbody> un <tfoot> palīdz grupēt rindas pēc nozīmes un var tikt izmantoti pārlūkprogrammās, lai optimizētu lielu tabulu attēlošanu. Šajās sadaļās atrodas <tr> elementi. <tr> iekšpusē ir <th> (parasti <thead>-ā, dažreiz <tbody> vai <tfoot>-ā) vai <td> ( <tbody> un <tfoot>-ā, dažreiz <thead>-ā).
Pamatstruktūras piemērs:
<table>
<caption>
Preču saraksts
</caption>
<thead>
<tr>
<th>Nosaukums</th>
<th>Cena</th>
</tr>
</thead>
<tbody>
<tr>
<td>Prece 1</td>
<td>100</td>
</tr>
<tr>
<td>Prece 2</td>
<td>150</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2">Kopā: 250</td>
</tr>
</tfoot>
</table>