Tabindex


Image by Leo Reynolds


New and Improved Tabbing

In HTML4, the tabindex attribute was limited to those elements that could receive focus, i.e. form elements. In HTML5, tabindex became a document-level attribute, enabling any element to receive tab focus. That means that even paragraphs, images, and spans may now receive focus. Here's a demo:

<input tabindex="3" placeholder="Will receive focus third"><br />
<input tabindex="-1" placeholder="Won't receive focus at all">    <br />
<input tabindex="2" placeholder="Will receive focus second"><br />
<input tabindex="1" placeholder="Will receive focus first">
<p tabindex="4"> This wouldn't normally receive focus</p>

Set the focus here to begin and press the TAB
key to navigate from one field to the next.




This wouldn't normally receive focus