
HTML <input> autofocus Attribute
- Definition and Usage. The autofocus attribute is a boolean attribute. When present, it specifies that an <input> element should automatically get focus when the page loads.
- Browser Support. The numbers in the table specify the first browser version that fully supports the attribute.
- Syntax
What is the autofocus attribute of the element?
The autofocus attribute of the <input> element is used to specify which of the <input> would get focus when the web page loads. This attribute introduced in HTML5.
What does the attribute do in HTML?
When present, it specifies that an <input> element should automatically get focus when the page loads. The numbers in the table specify the first browser version that fully supports the attribute.
What is the difference between HTML and XHTML autofocus?
Differences Between HTML and XHTML. In XHTML, attribute minimization is forbidden, and the autofocus attribute must be defined as <input autofocus="autofocus" />.

What is global autofocus?
The autofocus global attribute is a Boolean attribute indicating that an element should be focused on page load, or when the <dialog> that it is part of is displayed.
Can autofocus confuse people?
Automatically focusing a form control can confuse visually-impaired people using screen-reading technology and people with cognitive impairments. When autofocus is assigned, screen-readers "teleport" their user to the form control without warning them beforehand.
What is the autofocus property in HTML?
The HTMLSelectElement.autofocus property is a Boolean that reflects the autofocus HTML attribute , which indicates whether the associated <select> element will get input focus when the page loads, unless the user overrides it.
Does setting the focus property affect the element?
Setting this property doesn't set the focus to the associated <select> element: it merely tells the browser to focus to it when the element is inserted in the document. Setting it after the insertion, that is most of the time after the document load, has no visible effect.
