Open In App

HTML name Attribute

Improve
Improve
Like Article
Like
Save
Share
Report

The HTML name attribute labels elements, notably form inputs, identifying them for data submission. It’s crucial for form processing and is often used in JavaScript DOM manipulation. Unique within a form.

Note: This attribute has been DEPRECATED and is no longer recommended.

Supported tags:

ElementDescription
buttonRepresents a clickable button.
fieldsetGroups related form elements.
formContainer for form controls.
iframeEmbeds another HTML page.
inputAccepts user input.
mapDefines an image map.
metaProvides meta-information.
objectEmbeds external content.
outputDisplays calculation results.
paramProvides parameters for objects.
selectCreates a dropdown list.
textareaMultiline text input area.
keygenGenerates cryptographic keys.

Example of HTML name Attribute

Example 1: In this example we are displays GeeksforGeeks heading, form with username and password inputs, and submit button. Demonstrates the use of the button’s name attribute.

html
<!DOCTYPE html>
<html>
    <head>
        <title>HTML button name Attribute</title>
    </head>

    <body>

        <h3>HTML button name Attribute</h3>

        <form action="#" method="get">
            Username:
            <input type="text" name="uname" />

            <br /><br />

            Password:
            <input type="password" name="pwd" />

            <br /><br />

            <button type="submit" value="submit">
                Submit
            </button>
        </form>
    </body>
</html>

Output: 

buttonAttribute

HTML name Attribute Example Output

Example 2: In this example the HTML select element with name attribute defines a dropdown list. Each option has a value. Important for form submission and JavaScript DOM manipulation. 

HTML
<!DOCTYPE html> 
<html> 

<head> 
    <title> 
        HTML Select name Attribute 
    </title> 
</head> 

<body style="text-align:center;"> 

    <h2 > 
    HTML Select name Attribute 
    </h2> 
    <br> Select your preferred 
          course from the drop-down list: 
    <br> 

    <select name="Courses Titles" id="myCourses"> 
        <option value="C++">c++</option> 
        <option value="Placement">Placement</option> 
        <option value="Java">Java</option> 
        <option value="Python">Python</option> 
    </select> 

</body> 

</html> 

Output: 

NameAttribute

HTML name Attribute Example Output

Supported Browsers: The browsers supported by HTML | name Attribute are listed below: 



Last Updated : 26 Mar, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads