HTML 자동 초점 속성
정의 및 사용
autofocus
속성은 부울 속성입니다 .
존재하는 경우 페이지가 로드될 때 요소가 자동으로 포커스를 받아야 함을 지정합니다.
에 적용
속성 은
autofocus
다음 요소에 사용할 수 있습니다.
집단 | 기인하다 |
---|---|
<버튼> | 자동 초점 |
<입력> | 자동 초점 |
<선택> | 자동 초점 |
<텍스트 영역> | 자동 초점 |
예
버튼 예
자동 초점 버튼:
<button type="button" autofocus>Click Me!</button>
입력 예
페이지가 로드될 때 "이름" 입력 필드가 자동으로 포커스를 받도록 합니다.
<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>
텍스트 영역 예
자동 초점이 있는 텍스트 영역:
<textarea autofocus>
At w3schools.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea>
브라우저 지원
특성 은 autofocus
각 요소에 대해 다음 브라우저 지원을 가집니다.
Element | |||||
---|---|---|---|---|---|
form | 5.0 | 10.0 | 4.0 | 5.0 | 9.6 |
input | 5.0 | 10.0 | 4.0 | 5.0 | 9.6 |
textarea | Yes | 10.0 | 4.0 | Yes | Yes |