แอตทริบิวต์ HTML tabindex กำหนดลำดับแท็บขององค์ประกอบในเอกสาร HTML เป็นแอตทริบิวต์สากลซึ่งหมายความว่าสามารถใช้กับองค์ประกอบ HTML ใดก็ได้
ไวยากรณ์
ต่อไปนี้เป็นไวยากรณ์ -
<tagname tabindex=”number”></tagname>
ตัวอย่าง
ให้เราดูตัวอย่าง HTML tabindex Attribute -
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
height: 100vh;
background-color: #8BC6EC;
background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
text-align: center;
}
p {
font-size: 1.2rem;
}
</style>
<body>
<h1>HTML tabindex Attribute</h1>
<p tabindex="5">I'm paragraph.</p>
<p tabindex="4">I'm paragraph.</p>
<p tabindex="3">I'm paragraph.</p>
<p tabindex="2">I'm paragraph.</p>
<p tabindex="1">I'm paragraph.</p>
<p>Now, try to navigate through paragraph using tab key</p>
</body>
</html> ผลลัพธ์

ตอนนี้ให้ลองเลื่อนดูย่อหน้าโดยใช้ปุ่มแท็บ

