How to add default HTML form focus without JavaScript?

Spread the love

Sometimes, we want to add default HTML form focus without JavaScript.

In this article, we’ll look at how to add default HTML form focus without JavaScript.

How to add default HTML form focus without JavaScript?

To add default HTML form focus without JavaScript, we add the autofocus attribute.

For instance, we write

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

to add the autofocus attribute to focus on the input by default.

Conclusion

To add default HTML form focus without JavaScript, we add the autofocus attribute.

Leave a Reply

Your email address will not be published.