HTML5 introduce แอตทริบิวต์ใหม่ autofocus ใช้ดังนี้:
<input type="text" name="search" autofocus/>
แอตทริบิวต์นี้รองรับโดย Mozilla, Safari, Chrome เวอร์ชันล่าสุดเท่านั้น
ตัวอย่าง
ลองรันโค้ดเรียนรู้ autofocus attribute:
<!DOCTYPE HTML>
<html>
<body>
<form action="/cgi-bin/html5.cgi" method="get">
Enter email: <input type="text" name="newinput" autofocus/>
<p>Try to submit using Submit button</p>
<input type="submit" value="submit" />
</form>
</body>
</html>