Easy Tutorial
❮ Tag Bdo Canvas Settransform ❯

HTML <input> autofocus Attribute

HTML <input> Tag

Example

Set the "First name" input field to automatically gain focus when the page loads:


Browser Support

Internet Explorer 10, Firefox, Opera, Chrome, and Safari support the autofocus attribute.

Note: Internet Explorer 9 and earlier versions do not support the autofocus attribute for the <input> tag.


Definition and Usage

The autofocus attribute is a boolean attribute.

The autofocus attribute specifies that the <input> element should automatically get focus when the page loads.


Differences Between HTML 4.01 and HTML5

The autofocus attribute is new in HTML5.


Differences Between HTML and XHTML

In XHTML, attribute minimization is forbidden, and the autofocus attribute must be defined as <input autofocus="autofocus" />.


Syntax

❮ Tag Bdo Canvas Settransform ❯