How to set the focus to the first form field ?
In this article, we’ll discuss how to set focus on the first form field. By setting the focus on the first form field, we indicate the user from where to begin. It increases the readability of a form in a webpage. There are various approaches to do so, we’ll explain two of them with suitable examples.
Approach 1: Using HTML <input> autofocus attribute. Autofocus is a boolean attribute, used along with an <input> element in a form. The form field is focused on automatically when the page loads.