DEV Community

Amr Ataa
Amr Ataa

Posted on

Autofocus Attribute

Again, HTML5 removes the need for JavaScript solutions. If a particular input should be "selected," or focused, by default, we can now use the autofocus attribute.

<input type="text" name="someInput" placeholder="Douglas Quaid" required autofocus>
Enter fullscreen mode Exit fullscreen mode

There are some important points that you need to keep in mind while using the autofocus attribute. Use of this attribute can cause behavior such as auto-scrolling of the page on load or the appearance of dynamic keyboards on smartphones.

Top comments (0)