Open In App

What is the use of name Attribute in HTML ?

Last Updated : 19 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The “name” attribute in HTML is used to define the name of an element, such as a form control or an anchor tag. It primarily serves as an identifier for the element, allowing it to be referenced and manipulated by scripts or accessed via the DOM (Document Object Model) in JavaScript.

Syntax

<tagname name="name_value">Content</tagname>
Key Point Description
Uniqueness The value assigned to the “name” attribute should be unique within the context of the containing form or document.
Form Submission For form controls, the “name” attribute determines the key used to submit data to the server when the form is submitted.
Accessibility The “name” attribute facilitates accessibility by providing a reliable way to identify and interact with form elements programmatically.

Features

  • In form elements such as input fields, checkboxes, and radio buttons, the “name” attribute is crucial for identifying the data when the form is submitted to the server.
  • It enables server-side scripts to access and process form data submitted by users, using the “name” attribute value as the key.
  • JavaScript can utilize the “name” attribute to access and manipulate form elements dynamically, enhancing interactivity and user experience.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads