HTML name Attribute
Last Updated :
26 Mar, 2024
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:
Element | Description |
---|
button | Represents a clickable button. |
fieldset | Groups related form elements. |
form | Container for form controls. |
iframe | Embeds another HTML page. |
input | Accepts user input. |
map | Defines an image map. |
meta | Provides meta-information. |
object | Embeds external content. |
output | Displays calculation results. |
param | Provides parameters for objects. |
select | Creates a dropdown list. |
textarea | Multiline text input area. |
keygen | Generates 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:Â
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:Â
HTML name Attribute Example Output
Supported Browsers: The browsers supported by HTML | name Attribute are listed below:Â
Share your thoughts in the comments
Please Login to comment...