ใช้แท็ก ใน HTML เพื่อสร้างส่วนหัวของตาราง แท็ก HTML ใช้ในการเพิ่มส่วนหัวลงในตาราง แท็ก thead ใช้ร่วมกับแท็ก tbody และ tfoot ในการกำหนดแต่ละส่วนของตาราง (ส่วนหัว ท้ายกระดาษ เนื้อหา)
แท็ก HTML ยังสนับสนุนแอตทริบิวต์เพิ่มเติมดังต่อไปนี้ -
แอตทริบิวต์ | ค่า | คำอธิบาย |
---|---|---|
align | ขวา ซ้าย ศูนย์ ให้เหตุผล char | เลิกใช้ - การจัดตำแหน่งภาพ |
ถ่าน | ตัวอักษร | เลิกใช้ − ระบุอักขระที่จะจัดแนวข้อความ ใช้เมื่อ align ="char" |
charoff | พิกเซลหรือ % | เลิกใช้ − ระบุออฟเซ็ตการจัดตำแหน่ง (เป็นพิกเซลหรือค่าเปอร์เซ็นต์) กับอักขระตัวแรกตามที่ระบุด้วยแอตทริบิวต์ถ่าน ใช้เมื่อ align ="char" |
valign | top กลาง ล่าง พื้นฐาน | เลิกใช้ - การจัดตำแหน่งแนวตั้ง |
ตัวอย่าง
คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อเรียนรู้วิธีใช้แท็ก ใน HTML -
<!DOCTYPE html> <html> <head> <title>HTML thead Tag</title> </head> <body> <table style = "width:100%" border = "1"> <thead> <tr> <td colspan = "4">This is the head of the table</td> </tr> </thead> <tfoot> <tr> <td colspan = "4">This is the foot of the table</td> </tr> </tfoot> <tbody> <tr> <td>Cell 1</td> <td>Cell 2</td> <td>Cell 3</td> <td>Cell 4</td> </tr> <tr> ...more rows here containing four cells... </tr> </tbody> <tbody> <tr> <td>Cell 1</td> <td>Cell 2</td> <td>Cell 3</td> <td>Cell 4</td> </tr> <tr> ...more rows here containing four cells... </tr> </tbody> </table> </body> </html>