Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

HTML autofocus global attribute

Baseline2023
Newly available

Theautofocusglobal 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.

html
<input name="q" autofocus />

No more than one element in the document or dialog may have the autofocus attribute. If applied to multiple elements the first one will receive focus.

Note:Theautofocus attribute applies to all elements, not just form controls. For example, it might be used on acontenteditable area.

Accessibility concerns

Automatically focusing a form control can confuse visually-impaired people using screen-reading technology and people with cognitive impairments. Whenautofocus is assigned, screen-readers "teleport" their user to the form control without warning them beforehand.

Use careful consideration for accessibility when applying theautofocus attribute. Automatically focusing on a control can cause the page to scroll on load. The focus can also cause dynamic keyboards to display on some touch devices. While a screen reader will announce the label of the form control receiving focus, the screen reader will not announce anything before the label, and the sighted user on a small device will equally miss the context created by the preceding content.

Specifications

Specification
HTML
# dom-fe-autofocus

Browser compatibility

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp