Focus management in HTML

In the HTML5 working draft, the activeElement DOM attribute and the hasFocus() DOM method give the programmer the ability to have better control of the interactivity of the page due to the user's actions. For example, both of them can be used for statistical usage purposes, tracking the number of clicks on certain links of a page, measuring the amount of time an element is focused, and so forth. In addition, when combined with AJAX technology, they help minimize the number of requests to the server, depending on the user activity and the page layout.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support ? 3.6 (1.9.2)[1] ? ? ?
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? 4.0 (2.0)[1] ? ? ?

[1] Starting in Gecko 8.0 (Firefox 8.0 / Thunderbird 8.0 / SeaMonkey 2.5), Firefox now draws a focus ring around any element when it has a tabindex value greater than 0, instead of only a limited subset of items. There are only a few exceptions to this rule: <input>, <button>, <select>, <textarea>, <iframe>, <frame>, <body>, and <html>.

See also

Document Tags and Contributors

 Last updated by: Sebastianz,