ตาราง HTML ใช้สำหรับสร้างตารางโดยใช้แท็ก
| ข้อมูลตารางถูกกำหนดโดยใช้แท็ก | ไวยากรณ์ต่อไปนี้เป็นไวยากรณ์ - <table> <tr> <th>Table Header</th> <th>Table Header</th> </tr> <tr> <td>Table data</td> <td>Table data</td> </tr> <tr> <td>Table data</td> <td>Table data</td> </tr> </table> แอตทริบิวต์ตาราง HTML
องค์ประกอบคำบรรยาย HTMLนอกจากนี้เรายังสามารถตั้งค่าคำบรรยายสำหรับตารางโดยใช้องค์ประกอบคำบรรยาย HTML ไวยากรณ์ต่อไปนี้เป็นไวยากรณ์ - <caption>text</caption> ตัวอย่างให้เราดูตัวอย่างของตาราง HTML: <!DOCTYPE html>
<html>
<style>
body {
color: #000;
height: 100vh;
background-color: #8BC6EC;
background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
text-align: center;
}
table {
margin: 2rem auto;
width: 400px;
}
caption {
color: #fff;
font-size: 1.5rem;
}
</style>
<body>
<h1>HTML Tables</h1>
<table border="2">
<caption>Student Data</caption>
<tr>
<th>Name</th>
<th>Roll No.</th>
</tr>
<tr>
<td>John</td>
<td>031717</td>
</tr>
<tr>
<td>Elon</td>
<td>051717</td>
</tr>
</table>
</body>
</html> ผลลัพธ์
|
|---|
