In this section, we will learn what the autofocus attribute is and how to use it.
What is autofocus Attribute in HTML <select> Tag?
Using the autofocus attribute in HTML <select> element will set the focus on this element right after browsers loaded an HTML document.
This means after the page was loaded, because of this focus, users are able to move through the items of a <select> element with the arrow keys (Up and Down) on their keyboard.
HTML autofocus Attribute in <select> Tag Syntax:
<select name = “name” autofocus> </select>
<select> Tag autofocus Attribute Values
The autofocus attribute does not need a value. Simply put, the attribute in the opening tag of the <select> element and the dropdown list will take the focus immediately when the page is loaded.