In this section, we will learn what autofocus is and how to use it in HTML.
What is autofocus Attribute in HTML <input> Tag?
The autofocus attribute is used when we want the target input field gets the focus when the page is loaded.
Note: if there is more than one input field had the autofocus set for them, only the first field actually going to take the focus and the rest will be ignored.
HTML autofocus Attribute in <input> Tag Syntax:
<input type = “type” autofocus>
<input> Tag autofocus Attribute Values
The autofocus attribute is a Boolean attribute and hence it does not take any value. Simply use it in the target field and it will take the focus when the page is loaded.