HTML name attribute

name attribute specifies a unique name for the html elements. name attribute is very important because it is used to retrieve the data of form.

Example

<form action="files/name.php" method="post">
 <p>Username:<input type="text" name="fname"></p>
 <p>Password:<input type="password" name="password"></p>
 <p><input type="sign" name="sign" value="sign in"></p>
</form>
Try </>

name attribute value

The value of name attribute is plain text.

Related Tags

The tags that support this attribute are given below.

<input> tag

input tag represents an input field. name attribute specifies a unique name for the input control that is used to process the data. In the other words, this attribute is used in the back-end.

See the example given above.

<output> tag

The following example represents the product of two numbers in input field.

Example

<form oninput="op.value = x.valueAsNumber * y.valueAsNumber">
  <input name=x type=number >*
  <input name=y type=number >=
  <output name=op for="x y"></output>
 </form>

Try</>

<select> tag

The data of select element is manipulated by the name attribute.

Example

<form action="files/selectname.php" method="post">
<select name="scountry">
  <option> United States 
  <option> Japan 
  <option> United Kingdom 
  <option> Quait 
  <option> Egypt 
 </select>
 <input type="submit" name="country" value="Enter">
</form>

Try</>

<textarea> tag

textarea tag represents multi line resizeable textarea.

Example

<form action="files/textareaname.php" method="post">
 <p>Email: <input type="email" name="email"></p>
 <p>Comment:<textarea name="comment" cols="100" rows="100"> </textarea></p>
 <input type="submit" name="send">

Try</>

<iframe> tag

Here name attribute is used to browse the content in iframe element.

Example

<a href="http://www.codingb.com" target="open">Learn HTML</a>
 <iframe name="open" width="400px" height="400px">
 </iframe>

Try</>

<map> tag

The name attribute connects the image to the map element.

Example

<img src="files/three images.jpg" usemap="#shapes" alt="one shape of triangle">
 <map name="shapes">
 <area coords="13,122,50,61,86,123"  href="files/triangle.html" shape="poly">
 </map>

Try</>

<meta> tag

name represents keywords, description, author and application name.

<head>
 <meta name="keywords" value="unique comma separated keywords">
 <meta name="description" value="A brief description about the page">
</head>


Was this article helpful?

 

Email:

Message:

Get the newsletter