HTML <input> autofocus 속성

정의와 사용법

autofocus 속성은 페이지가 로드될 때 input 요소가 자동으로 포커스를 얻도록 규정합니다.

autofocus 속성은 보리얼 속성입니다.

이 속성이 설정되어 있다면, <input> 요소가 페이지가 로드될 때 자동으로 포커스를 얻도록 규정합니다.

예제

페이지 로드 시 'First name' 입력 필드가 자동으로 포커스를 받도록 설정하십시오:

<form action="/action_page.php">
  <label for="fname">이름:</label>
  <input type="text" id="fname" name="fname" autofocus><br><br>
  <label for="lname">성씨:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit">
</form>

직접 시험해 보세요

문법

<input autofocus>

브라우저 지원

표에서의 숫자는 이 속성을 최초로 완전히 지원하는 브라우저 버전을 나타냅니다.

크롬 에지 파이어폭스 사파리 오페라
크롬 에지 파이어폭스 사파리 오페라
5.0 11.0 4.0 5.0 9.6

주의사항:autofocus 속성은 HTML5에서 새로운 속성입니다.