[whatwg] Focus, html vs body and the activeElement property

Hans S. Tømmerholt hanst at opera.com
Wed Apr 30 01:08:31 PDT 2008


I'm reading this part:

The intro states:
"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

Under "Focus management", I read:

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

First: Isn't this a contradiction? The first paragraph states that there
is always an element focused. The second gives a case where this is not so.

Second: I presume the document's root is defined as html, but the
activeElement returns the body element. Why?

This seems to refer to the same issue:
Searching through the archive I can't find a response, for example in  
Ian's "several messages" posts.

The spec also mentions "system focus" and seems to imply that this is
different from the focus of elements. But the term is not particularly
defined. I'm guessing this means that this is the page the user is
currently looking at, i.e. that the window containing the document has
focus? But then this line is confusing:

"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."

This seems to imply that an element inside a document can have system
focus. What does this mean?

Vennlig hilsen/best regards
Hans S. Tømmerholt
Developer, Web Applications, Opera Software ASA

More information about the whatwg mailing list