HTML input autofocus Attribute Last Updated : 22 Feb, 2025 Comments Improve Suggest changes Like Article Like Report The autofocus attribute in HTML is used to specify that a particular form element (like an input field, textarea, or select dropdown) should automatically receive focus when the page is loaded, allowing the user to start interacting with it immediately without needing to click on it.Syntax<input autofocus>Note: It is a Boolean Attribute means it doesn't need any value.ExampleTip: Run this code, without using the autofocus attribute. HTML <!DOCTYPE html> <html> <head> <title> HTML input autofocus Attribute </title> </head> <body style="text-align:center"> <h1 style="color: green;"> GeeksforGeeks </h1> <h2> HTML input autofocus Attribute</h2> Name: <input autofocus="" type="text"/> <br/> <br/> <!-- Assign id to the Button. --> <button id="GFG"> Submit </button> <br/> </body> </html> Output:HTML input autofocus AttributeSupported BrowsersThe browser supported by HTML <input>autofocus Attribute are listed below:Google ChromeInternet ExplorerFirefoxOperaSafariImportant Points About AutoFocus Attributeautofocus is a simple, effective way to improve the user experience by directing the user's attention to a specific form element immediately upon page load.Only one element should have the autofocus attribute on a page to avoid unexpected behavior.It enhances usability, especially in forms and interactive elements, but should be used with care, especially with accessibility considerations in mind. Comment More infoAdvertise with us Next Article HTML | input readonly Attribute M manaschhabra2 Follow Improve Article Tags : Web Technologies HTML HTML-Attributes Similar Reads HTML <input> align Attribute The HTML <input> align attribute is used with <input type=â imageâ> to set the horizontal alignment of the image. It is not supported by HTML 5. Note: Since <input type=â imageâ> is not supported by HTML5 you can use CSS there instead of this attribute. The syntax for CSS <input 1 min read HTML input maxlength Attribute The maxlength attribute in the HTML <input> element is used to define the maximum number of characters that can be entered into the field. If no value is specified, or if an invalid value is provided, the input field will have no maximum length. The length is determined in UTF-16 code units, w 2 min read HTML | <input> name Attribute The HTML <input> name Attribute is used to specify a name for an <input> element. It is used to reference the form-data after submitting the form or to reference the element in a JavaScript. Syntax: <input name="name"> Attribute Values: It contains a single value name which describ 1 min read HTML | <input> list Attribute The HTML <input> list Attribute is used to identify a list of pre-defined options for an element to suggest the user. Syntax: <input list="datalist_id"> Attribute Values: datalist_id: It is used to specify the Id of the datalist that will used to make a link up with the input element. Ex 1 min read HTML | <input> required Attribute The HTML required Attribute is a Boolean attribute which is used to specify that the input element must be filled out before submitting the Form. This attribute works with other types of input like radio, checkbox, number, text, etc.Syntax: <input required> Example-1: This Example that illustr 1 min read HTML <input> disabled Attribute The disabled attribute for <input> element in HTML is used to specify that the input field is disabled. A disabled input is un-clickable and unusable. It is a boolean attribute. The disabled <input> elements are not submitted in the form. Syntax: <input disabled> Example: html < 1 min read HTML <input> type Attribute The HTML <input> type Attribute is used to specify the type of <input> element to display. The default type of <input> type attribute is text. Syntax: <input type="value">Attribute Values: Name Description button Defines clickable button in HTML document, commonly activated w 3 min read HTML input autofocus Attribute The autofocus attribute in HTML is used to specify that a particular form element (like an input field, textarea, or select dropdown) should automatically receive focus when the page is loaded, allowing the user to start interacting with it immediately without needing to click on it.Syntax<input 1 min read HTML | input readonly Attribute The readonly attribute of <input> element in HTML is used to specify that the input field is read-only. If an input is readonly, then it's content cannot be changed but can be copied and highlighted. It is a boolean attribute. Syntax: <input readonly> Example: This example uses HTML < 1 min read HTML < input> accept Attribute The HTML <input> accept attribute is used to control the type of files that can be selected for input, restricting the file selection to specific formats such as image/* for images or .pdf for PDF files. Syntax: <input accept = "file_extension | audio/* | video/* | image/* | media_type"> 4 min read Like