[whatwg] [Web Forms 2.0] autofocus attribute

Ian Hickson ian at hixie.ch
Mon Aug 14 02:56:02 PDT 2006

On Sat, 28 Jan 2006, Grey wrote:
> "Authors should avoid setting the autofocus attribute on multiple 
> enabled elements in a document. If multiple elements with the autofocus 
> attribute set are inserted into a document, each one will be processed 
> as described above, as they are inserted. This means that during 
> document load, for example, the last focusable form control in document 
> order with the attribute set will end up with the focus."
> That does not really make sense for me. Why in the world should anyone 
> want such behavior?

They wouldn't. That's why authors shouldn't set it more than once.

> If you want to change the focus on-the-fly there are propably better 
> ways to do that. I had asked the vednors to include the option "only 
> focus on first" but as you're right at the roots, I think I should 
> comment on that this way.
> I would appreciate to not allow multiple auto-focus attributes used in one
> document.

They're not. Authors "should avoid setting the autofocus attribute on 
multiple enabled elements in a document" means that it is wrong to do so.

> But what, for example, if we have a frameset running with 3 framed html 
> pages, each using autofocus? The navigation could have a site-search on 
> top and the other two could also have essential/important fields (or 
> simply the only ones viable for editing). So it may be a good idea to 
> restrict the autofocus on "parts" of the sites. This would be; identify 
> an autofocus attribute with the element using it and some parent (or 
> grandparent) ID. So if you hover any parts inside this [grand]parent, 
> the focus should be on the child containing the autofocus attribute.

Well, it depends on the UA, but it is quite possible for the UA to have a 
concept of "focussed control" per-frame, and then the concept of a 
focussed frame, in which case this works fine.

> So wait - this is contradictory !? Well, the easiest senseful of 
> handling autofocus is in my opinion only one per page, period. But if 
> this is going to be widened and fulfilling a certain purpose, I think my 
> other idea might not be too wrong. At least text box/area focus should 
> go well with it (displaying the blinking cursor).

I agree it should just be one-per-page. The spec already disallows more 
than one per page.

Sorry it took so long to reply.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list