This is a snapshot of an early working draft and has therefore been superseded by the HTML standard.

This document will not be further updated.


Call For Comments — 27 October 2007

3.5. Interaction

3.5.1. Activation

The click() method must fire a click event at the element, whose default action is the firing of a further DOMActivate event at the same element, whose own default action is to go through all the elements the DOMActivate event bubbled through (starting at the target node and going towards the Document node), looking for an element with an activation behavior; the first element, in reverse tree order, to have one, must have its activation behavior executed.

3.5.2. Focus

When an element is focused, key events received by the document must be targeted at that element. There is always an element focused; in the absence of other elements being focused, the document's root element is it.

Which element within a document currently has focus is independent of whether or not the document itself has the system focus.

Some focusable elements might take part in sequential focus navigation. Focus management

The focus() and blur() methods must focus and unfocus the element respectively, if the element is focusable.

Some elements, most notably area, can correspond to more than one distinct focusable area. When such an element is focused using the focus() method, the first such region in tree order is the one that must be focused.

Well that clearly needs more.

The activeElement attribute must return the element in the document that has focus. If no element specifically has focus, this must return the body element.

The hasFocus attribute must return true if the document, one of its nested browsing contexts, or any element in the document or its browsing contexts currently has the system focus. Sequential focus navigation

This section on the tabindex attribute needs to be checked for backwards-compatibility.

The tabindex attribute specifies the relative order of elements for the purposes of sequential focus navigation. The name "tab index" comes from the common use of the "tab" key to navigate through the focusable elements. The term "tabbing" refers to moving forward through the focusable elements.

The tabindex attribute, if specified, must have a value that is a valid integer.

If the attribute is specified, it must be parsed using the rules for parsing integers. If parsing the value returns an error, the attribute is ignored for the purposes of focus management (as if it wasn't specified).

A positive integer or zero specifies the index of the element in the current scope's tab order. Elements with the same index are sorted in tree order for the purposes of tabbing.

A negative integer specifies that the element should be removed from the tab order. If the element does normally take focus, it may still be focused using other means (e.g. it could be focused by a click).

If the attribute is absent (or invalid), then the user agent must treat the element as if it had the value 0 or the value -1, based on platform conventions.

For example, a user agent might default textarea elements to 0, and button elements to -1, making text fields part of the tabbing cycle but buttons not.

When an element that does not normally take focus (i.e. whose default value would be -1) has the tabindex attribute specified with a positive value, then it should be added to the tab order and should be made focusable. When focused, the element matches the CSS :focus pseudo-class and key events are dispatched on that element in response to keyboard input.

The tabIndex DOM attribute reflects the value of the tabIndex content attribute. If the attribute is not present (or has an invalid value) then the DOM attribute must return the UA's default value for that element, which will be either 0 (for elements in the tab order) or -1 (for elements not in the tab order).

3.5.3. Scrolling elements into view

The scrollIntoView([top]) method, when called, must cause the element on which the method was called to have the attention of the user called to it.

In a speech browser, this could happen by having the current playback position move to the start of the given element.

In visual user agents, if the argument is present and has the value false, the user agent should scroll the element into view such that both the bottom and the top of the element are in the viewport, with the bottom of the element aligned with the bottom of the viewport. If it isn't possible to show the entire element in that way, or if the argument is omitted or is true, then the user agent must instead simply align the top of the element with the top of the viewport.

Non-visual user agents may ignore the argument, or may treat it in some media-specific manner most useful to the user.