IHTMLAnchorElement::tabIndex Property

Sets or retrieves the index that defines the tab order for the object.


HRESULT IHTMLAnchorElement::get_tabIndex(short *p);
HRESULT IHTMLAnchorElement::put_tabIndex(short v);


  • p
    Pointer to a variable of type short that receives the tab index.
  • v
    short that specifies the tab index.

Possible Values

0 Default.

Return Value

Returns S_OK if successful, or an error value otherwise.


The IHTMLAnchorElement::tabIndex value determines the tab order as follows:

  1. Objects with a positive IHTMLAnchorElement::tabIndex are selected in increasing tab index order and in source order to resolve duplicates.
  2. Objects with an IHTMLAnchorElement::tabIndex of zero are selected in source order.
  3. Objects with a negative IHTMLAnchorElement::tabIndex are omitted from the tabbing order.

An element can have focus if the IHTMLAnchorElement::tabIndex property is set to any valid negative or positive integer.

The following elements can have focus and are tab stops by default: a, BODY, button, frame, iframe, img, input, isIndex, object, select, textArea.

The following elements can have focus by default but are not tab stops. These elements can be set as tab stops by setting the IHTMLAnchorElement::tabIndex property to a positive integer. applet, div, frameSet, span, table, td.

Setting the tHead and tFoot elements to participate in the tab order will not cause the focus rectangle to display when either receives focus.

Elements can become part of the accessibility hierarchy if the TABINDEX attribute is set as follows:

  • For Microsoft Internet Explorer 5.01 and later, set the TABINDEX attribute to any value.
  • For Internet Explorer 5, set the TABINDEX attribute to a positive value.

For Internet Explorer 5.01 or above, the attribute may be set to any value in the valid range of -32767 to 32767.

Content of elements with a closing tag can have focus by default, but are not tab stops. As of Internet Explorer 5, you can set the IHTMLAnchorElement::tabIndex property to a valid positive integer to force the content to have a tab stop.

Elements that receive focus can fire the onblur and onfocus events as of Internet Explorer 4.0, and the onkeydown, onkeypress, and onkeyup events as of Internet Explorer 5.