The tabindex Attribute

The tabindex attribute controls the order in which the tab key moves the focus through the HTML page.

 
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
</head>
<body>
      <form>
            <label>Name: <input type="text" name="name" tabindex="1" /></label>
            <p />
            <label>City: <input type="text" name="city" tabindex="-1" /></label>
            </p>
            <label>Country: <input type="text" name="country" tabindex="2" /></label>
            </p>
            <input type="submit" tabindex="3" />
      </form>
</body>
</html>
  

An element with tabindex value of 1 is selected first. When pressing the Tab key, the element with a tabindex of 2 will be selected. A tabindex value of -1 ensures that an element will not be selected when the user presses the Tab key.

Home 
  HTML CSS Book 
    HTML  

HTML5 Global Attributes:
  1. The accesskey Attribute
  2. The class Attribute
  3. The contenteditable Attribute
  4. The contextmenu Attribute
  5. The dir Attribute
  6. The draggable Attribute
  7. The dropzone Attribute
  8. The hidden Attribute
  9. The id Attribute
  10. The lang Attribute
  11. The spellcheck Attribute
  12. The style Attribute
  13. The tabindex Attribute
  14. The title Attribute
Related: