English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The autofocus attribute is a boolean attribute. The autofocus attribute specifies that the <input> element should automatically receive focus when the page loads.
When the page loads, automatically focus on the name="fname" field:
<!DOCTYPE html> <html> <head> <title>HTML: <input> autofocus attribute - 基础教程网(oldtoolbag.com)</title> <body> <form action="action_page.php"> First name: <input type="text" name="fname" autofocus><br> Last name: <input type="text" name="lname"><br> <input type="submit"> </form> </body> </html>Test to see ‹/›
IEFirefoxOperaChromeSafari
Internet Explorer 10Firefox, Opera, Chrome and Safari support the autofocus attribute.
Note:Internet Explorer 9 and earlier versions do not support the autofocus attribute of the <input> tag.
The autofocus attribute is a boolean attribute.
The autofocus attribute specifies that the <input> element should automatically receive focus when the page is loaded.
The autofocus attribute is an HTML5 new attributes.
In XHTML, attribute shorthand is prohibited, the autofocus attribute must be defined as <input autofocus="autofocus" />.
<input autofocus>