Dynamic Web Lab
Back to insights

HTML5 input autofocus Attribute

September 15, 20121 min read

HTML5 allows us input autofocus attribute on elements when page loads.
This is accomplished by using the autofocus attribute.
Using this autofocus attribute the INPUT, TEXTAREA, or BUTTON element will be automatically selected on page load.

The best part is no JavaScript is needed.

This autofocus attribute can be set using this 3 ways :

[php]
<input autofocus>
<input autofocus="autofocus">
<input autofocus="">
[/php]

The autofocus attribute is supported in all major browsers, except Internet Explorer.

Writer

Dynamic Web Lab Editorial

We share how we design, engineer, and scale digital products across the GCC, Europe, and the US.

Share this article

Tags

HTML5

Need help implementing this?

We turn these playbooks into shipped features. Let us scope your roadmap and support your team.

Start a project conversation