- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to specify that the element should automatically get focus when the page loads in HTML?
Use the autofocus attribute to specify that the element should get focus automatically on page load in HTML −
Example
You can try to run the following code to learn how to implement 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>
- Related Articles
- How to specify that an element should be pre-selected when the page loads in HTML?
- How to specify that an option should be pre-selected when the page loads in HTML?
- How to specify if and how the author thinks the audio/video should be loaded when the page loads in HTML?
- How to specify that the form should not be validated when disabled in HTML?
- How to specify whether the or the element should have autocomplete enabled in HTML?
- How to specify that the element is read-only in HTML?
- How to specify that the details should be visible to the user in HTML?
- Execute a script when the element loses focus in HTML?
- Execute a script when the element gets focus in HTML?
- How to place the cursor (auto focus) in the text box when a page gets loaded with HTML?
- How to specify whether the content of an element should be translated or not in HTML?
- How to specify the URL of the page the link goes to in HTML?
- How to specify the HTML content of the page to show in the <iframe> in HTML?
- How to specify that the element must be filled out before submitting the form in HTML?
- How to specify that an element is not yet relevant in HTML?

Advertisements