How to specify the name of an input element? Last Updated : 24 Jun, 2024 Comments Improve Suggest changes Like Article Like Report To add the name of an input element, we use the 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 JavaScript. Syntax:<input name="name">Attribute Values: It contains a single value name that describes the name of the <input> element. Example 1: In this example, define an input element within a form, setting its name attribute to specify its identifier. Surround the input field with a <label> tag, using the for attribute to associate it with the input's id, aiding accessibility and user experience. HTML <!DOCTYPE html> <html lang="en"> <head> <title> How to specify the name of an input element using HTML? </title> </head> <body style="text-align: center;"> <h3> How to specify the name of an input element using HTML </h3> <form id="myGeeks"> <label for="GFG">Username</label> <input type="text" id="GFG" name="GFG"> <br><br> <label for="GFG1">Password</label> <input type="password" id="GFG1" name="GFG1"> <br><br> <input type="submit" name="submit"> </form> </body> </html> Output: OutputExample 2: The HTML code creates a webpage titled "HTML Input name Attribute" with a centered layout. It includes a form with an input field named "geeks" and a pattern attribute enforcing a specific input format. HTML <!DOCTYPE html> <html> <head> <title> HTML Input name Attribute </title> </head> <body style="text-align:center;"> <h1>GeeksForGeeks</h1> <h2>HTML Input name Attribute</h2> <form id="myGeeks"> <input type="text" id="text_id" name="geeks" pattern="[A-Za-z]{3}" value="Manas Chhabra"> </form> <br> </body> </html> Output: Output Comment More infoAdvertise with us Next Article How to specify the name of an input element? V vkash8574 Follow Improve Article Tags : Web Technologies HTML HTML-Misc HTML-Questions Similar Reads How to specify a name for the output element in HTML? The name attribute specifies the name of an <output> element. It is used to reference form data after it has been submitted, or to reference the element in JavaScript. The <output> tag is used to represent the result of a calculation. The HTML <for> type attribute is used because i 1 min read How to specify the type of an input element using HTML ? In this article, we will specify the type of an input element using HTML. 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: button: It i 4 min read How to specify the value of an input element using HTML ? In this article, we will set the value of an input element using HTML. The value attribute for <input> element in HTML is used to specify the initial value of the input element. It has different meaning for different input type: The âbuttonâ, âresetâ and âsubmitâ property specifies the text on 1 min read How to specify a name for the fieldset using HTML ? The <fieldset> tag in HTML5 is used to make a group of related elements in the form and it creates the box over the elements. The <fieldset> tag is new in HTML5. The HTML <fieldset> name attribute is used to specify the name for the fieldset element. It is used to reference the for 1 min read How to select an element by name with jQuery ? Selecting an element by name with jQuery allows you to target HTML elements using their `name` attribute. This method is commonly used in form handling, where input fields, checkboxes, or radio buttons share the same name, enabling you to easily manipulate or retrieve their values.Table of ContentUs 3 min read Like