แอตทริบิวต์ rowspan ใน HTML ใช้กำหนดจำนวนแถวที่เซลล์ของตารางควรกลุม (span) ในเอกสาร HTML สามารถใช้ได้เฉพาะกับองค์ประกอบ td หรือ th เท่านั้น
ไวยากรณ์
<tagname rowspan="number"></tagname>
ตัวอย่าง
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
background: lightblue;
height: 100vh;
text-align: center;
}
table {
margin: 2rem auto;
width: 400px;
}
</style>
<body>
<h1>ตัวอย่างแอตทริบิวต์ rowspan ของ HTML</h1>
<table border="2">
<thead>
<tr>
<th>ชื่อ</th>
<th>ภาษา</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>อังกฤษ</td>
</tr>
<tr>
<td rowspan="2">Elon</td>
<td>เยอรมัน</td>
</tr>
<tr>
<td>ฝรั่งเศส</td>
</tr>
</tbody>
</table>
</body>
</html>
ผลลัพธ์
แสดงตารางที่เซลล์ "Elon" กลุม 2 แถว (rowspan=2)