A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

How should browsers treat the autofocus attribute on mobile devices?


If you open https://www.wikipedia.org/ in an Android browser, the search field will be focused and there will be a blinking caret inside it. This is because the website uses the autofocus attribute.

However, browsers do not pull up the virtual keyboard as well, so the user sees a blinking caret but has no way of typing into it.

This seems like a bug. A blinking caret is a “start typing” signal, so it should only be shown on mobile devices if the keyboard is also shown.

I think it would make more sense if browsers just ignored the autofocus attribute on devices that don’t have a physical keyboard. That way, responsive websites would not have to guess if a such a keyboard is present and set the autofocus attribute only in that case.