Use the autofocus attribute to specify that an element should automatically gain focus when the page is loaded in HTML -
You can try running the following code to learn how to implement the autofocus attribute in HTML -
<!DOCTYPE html> <html> <body> <p>Click on the below button to generate an alert box.</p> <button type = "button" autofocus onclick = "alert('Welcome!')">Result</button> </body> </html>
The above is the detailed content of How to specify in HTML that an element automatically gets focus when the page loads?. For more information, please follow other related articles on the PHP Chinese website!