ใช้แท็ก <caption> เพื่อเพิ่มคำอธิบายหรือหัวข้อให้กับตารางใน HTML แท็กนี้ต้องวางไว้ทันทีหลังแท็ก <table> เปิด
ตัวอย่างการใช้งาน
ตัวอย่างด้านล่างแสดงตารางพร้อมคำอธิบาย "นักคริกเก็ตอินเดีย":
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
padding: 8px;
}
</style>
</head>
<body>
<h2>นักคริกเก็ต</h2>
<table style="width:100%">
<caption>นักคริกเก็ตอินเดีย</caption>
<tr>
<th>ชื่อ</th>
</tr>
<tr>
<td>Sachin Tendulkar</td>
</tr>
<tr>
<td>Virat Kohli</td>
</tr>
</table>
</body>
</html>
คำแนะนำ: ควรใช้ CSS เพื่อจัดรูปแบบตารางแทนการใช้แอตทริบิวต์เก่าๆ เช่น border ในแท็ก table โดยตรง