Which element should I use for titles of tables, <caption>
or <th>
?
For example, I want to create this table :
What is better,
<tr><th colspan="2">Discographie</th></tr>
or
<caption style="font-weight: bold">Discographie</caption>
?
th
corresponds to the title of the column, so in that case : "Album" and "Année"
W3C : "The th element represents a header cell in a table." https://www.w3.org/WAI/tutorials/tables/one-header/
caption
corresponds to the title / description of the whole table, so yes, you'd better use caption for "Discographie".
W3C : "The caption element represents the title of the table that is its parent." https://www.w3.org/WAI/tutorials/tables/caption-summary/
Plus, it is easier to maintain as your table grows
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With