Android / iOS input focused on tapping on page body

Question about a standard browser showing an HTML5 page, not a WebView

The test device is the Galaxy Tab 10.1, although this was also seen on the iPad.

The page has a form. The shape has a fixed width and

margin-left: auto; margin-right: auto; 

When I touch and hold the body of the page ( outside the form ), one of the inputs of the form (usually the 1st, although sometimes the second) focuses (and the on-screen keyboard is shown).

Any explanation why this behavior? Any idea how to prevent this?

+6
source share
1 answer

Use the HTML5 autofocus attribute to make the browser focus on the element first.

 <input autofocus="autofocus" /> 

Older browsers will ignore the attribute.

0
source

Source: https://habr.com/ru/post/920320/


All Articles