English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

Complete List of HTML Tags

HTML: <select> autofocus attribute

The autofocus attribute of the <select> element is a boolean attribute. If present, it specifies that the dropdown list should automatically receive focus when the page is loaded.

 HTML <select> tag

Online Example

Dropdown list with autofocus:

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>HTML:<select> autofocus attribute usage-基础教程(oldtoolbag.com)/title> 
</head>
<body>
<select autofocus>
<option value="php">PHP</option>
<option value="java">Java</option>
<option value="rust">Rust</option>
<option value="pythone">Python</option>
</select>
</body>
</html>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

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

Note:Firefox or Internet Explorer 9 and earlier versions do not support the autofocus attribute of the <select> tag.

Definition and Usage

The autofocus attribute is a boolean attribute.

The autofocus attribute specifies that the dropdown list automatically receives focus when the page is loaded.

HTML 4.01 versus HTML5difference

The autofocus attribute is an HTML5 New attributes of the <select> tag.

Differences between HTML and XHTML

In XHTML, attribute shorthand is prohibited, and the autofocus attribute must be defined as <select autofocus="autofocus">.

Syntax

<select autofocus>
 HTML <select> tag