How to get focused a button automatically when the page load using HTML ? Last Updated : 01 Oct, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The <button> tag in HTML is used to define the clickable button. The <button> tag is used to submit the content. The images and text content can use inside <button> tag. The <button> autofocus attribute is used to get focused button automatically after loading the web pages. Syntax: <button type="" autofocus> Submit <button> Example 1: HTML <!DOCTYPE html> <html> <body> <h1 style="color:green;"> GeeksforGeeks </h1> <h3> How to specify that a button should automatically get focus when the page load? </h3> <!-- button tag starts from here --> <button type="button" autofocus onclick="alert('Welcome to GeeksforGeeks')"> Click Here </button> <!-- button tag ends here --> </body> </html> Output: On click of the submit button, the following alert message box is shown to the user. Example 2: HTML <!DOCTYPE html> <html> <body> <h1 style="color:green;"> GeeksforGeeks </h1> <h3> How to specify that a button should automatically get focus when the page load? </h3> <!-- button tag starts from here --> <button type="button" autofocus onclick="myFun()"> Click Here </button> <!-- button tag ends here --> <p id=result></p> <script> function myFun() { document.getElementById("result") .innerHTML = "Welcome to GeeksforGeeks"; } </script> </body> </html> Output: Comment More infoAdvertise with us Next Article How to set focus on input field automatically on page load in AngularJS ? V vkash8574 Follow Improve Article Tags : Web Technologies HTML HTML-Questions Similar Reads How to set a keygen element that automatically get focused when page loads in HTML5 ? The <keygen> tag in HTML is used to specify a key-pair generator field in a form. The purpose of this element is to provide a secure way to authenticate users. When a form is submitted then two keys are generated, private key and public key. The private key is stored locally, and the public ke 1 min read How to set the focus on drop-down list automatically when the page loads in HTML5? The purpose of this article is to focus the drop-down list automatically when the page loads in HTML5. The <select> autofocus attribute is a boolean attribute that specifies that the drop-down list should automatically get focus when the page loads. Syntax: <select autofocus> Example: Th 1 min read How to focus element while loading the page in HTML ? HyperText Markup Language(HTML) is the basic building block of web pages that defines a structure. This markup language is used by browsers to manipulate data like text, images, and other content so that they can be displayed in the required format. HyperText refers to the links that connect web pag 3 min read How to set focus on input field automatically on page load in AngularJS ? We can focus on any input field automatically using the angular directives. Here we create a custom directive that can auto-focus on any field in the form. Creating a custom directive is just like creating an Angular component. To create a custom directive we have to replace @Component decorator wit 3 min read How to Link a Button to Another Page in HTML? Linking a button to another page is a common requirement in web development. It can allow the users to navigate between a website's different sections or pages. This can be done using the various HTML elements.PrerequisitesHTMLCSS1. Using <a> Tag Styled as ButtonThe <a> tag is traditiona 3 min read How to pre-select an input element when the page loads in HTML5? In this article, we are going to pre-select an input element when the page loads i.e. the user doesn't have to click the first text box to start writing on it. When the page is loaded the input is to be pre-selected and the user can start typing directly. This can be done by using the autofocus attr 1 min read Like