XHTML » XHTML Core Tag » tabindex

Syntax:
tabindex="number"

The tabindex attribute specifies an integer that defines the rank in the tabbing order for the specified element when you use the keyboard to navigate (tab through) a page.

The lower the integer, the higher the ranking in the tabbing order. A higher rank is tabbed to before a lower rank. The integer cannot be negative or zero.
 

Examples

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>DevGuru XHTML tabindex Attribute Example</title>
</head>
<body>
<form>
Place the cursor in the top input window.
<br />
Then type the <b>tab</b> button on the keyboard.
<br />
Note that after the "First Name" we jump over "Last Name" to "Maiden Name".
<br />
After "Maiden Name" we return up to "Last Name".
<br />
<hr />
<br />
First Name: (tabindex = 1)
<br />
<input type="text" name="firstlname" size="30" tabindex="1" />
<br />
Last Name: (tabindex = 3)
</br>
<input type="text" name="lastname" size="30" tabindex="3" />
<br />
Maiden Name: (tabindex = 2)
<br />
<input type="text" name="maidenname" size="30" tabindex="2" />
</form>
</body>
</html>
Output:
Place the cursor in the top input window.
Then type the tab button on the keyboard.
Note that after the "First Name" we jump over "Last Name" to "Maiden Name".
After "Maiden Name" we return up to "Last Name".


First Name: (tabindex = 1)

Last Name: (tabindex = 3)

Maiden Name: (tabindex = 2)
Language(s): XHTML

See Also: