TUTORIALReferencesFETCHED

HTML <button> autofocus 属性

HTML &lt;button&gt; autofocus 属性 HTML &lt;button&gt; 标签 实例 按钮使用 autofocus 属性: &lt;button type='button' autofocus&gt;点我!&lt;/button&gt; 尝试一下 » 浏览器支持 Internet Explore..

Updated 7/16/2026

Tutorial detail pages default to noindex.

HTML <button> autofocus 属性

HTML button 标签参考手册 HTML <button> 标签

实例

按钮使用 autofocus 属性:

<button type="button" autofocus>点我!</button>

尝试一下 »

浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 10, Firefox, Chrome, 和 Safari 支持autofocus 属性。

注意: Internet Explorer 9 以及更早IE版本不支持 autofocus 属性。


定义和用法

autofocus 属性是一个 boolean(布尔) 属性。

autofocus 属性规定当页面加载时按钮应当自动地获得焦点。


HTML 4.01 与 HTML5之间的差异

autofocus 属性是 HTML5 <button> 标签的新属性。


HTML 与 XHTML之间的差异

在 XHTML 中, 不允许属性简写,autofocus 属性必须定义为 <button autofocus="autofocus">。


语法

<button type="button" autofocus>


HTML button 标签参考手册 HTML <button> 标签