captionタグの概要
captionタグは、テーブルのキャプション(表題)を定義するためのタグです。テーブル内の内容の要約や説明を追加する際に使用されます。
captionタグの基本の書き方(構文)
<table>
<caption>This is a table caption</caption>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
captionタグの使用例
<table>
<caption>Monthly Sales Report</caption>
<tr>
<th>Month</th>
<th>Revenue</th>
</tr>
<tr>
<td>January</td>
<td>$1000</td>
</tr>
</table>
<table>
<caption>Population Statistics</caption>
<tr>
<th>Country</th>
<th>Population</th>
</tr>
<tr>
<td>Japan</td>
<td>126 million</td>
</tr>
</table>
captionタグのよくある注意点・間違い
captionタグはtableタグ内でのみ使用することができます。テーブルのキャプションを表示する際に、必ずこのタグを使用するように注意しましょう。