The HTML <button> autofocus Attribute is used to specify whether the button should get automatically get focused or not when the page loads. It is a Boolean Attribute.
Syntax:
<button type="button" autofocus>
Example: This Example illustrates the use of autofocus attribute in Button Element.
html
<!DOCTYPE html>
< html >
< head >
< title >
HTML button autofocus Attribute
</ title >
</ head >
< body style = "text-align:center" >
< h1 style = "color: green;" >
GeeksforGeeks
</ h1 >
< h2 >
HTML button autofocus Property
</ h2 >
< button id = "GFG" autofocus>
Submit
</ button >
< br >
</ body >
</ html >
|
Output:

HTML button autofocus Property
Supported Browsers:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
04 Jul, 2023
Like Article
Save Article