The HTML tabindex attribute define the tab order of an element in an HTML document. It is a global attribute that means it can be used on any HTML element.
Syntax
Following is the syntax −
<tagname tabindex=”number”></tagname>
Example
Let us see an example of 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>
Output
Now try to navigate through paragraph using the tab key.