How to set focus on an HTML input box on page load?

Spread the love

To set focus on an HTML input box on page load, we add the autofocus attribute.

For instance, we write

<input type="text" name="fname" autofocus />

to add the autofocus attribute to focus on the input when the page is loaded.

Leave a Reply

Your email address will not be published. Required fields are marked *