The name Attribute

The Current State of HTML5 Forms

<input type="text" name="foo">
<input type="text" name="bar">
<input type="submit" name="submit" value="Test me">
<ol>
 <li><input type="radio" name="rbtn" value="1"> 1st Choice</li>
 <li><input type="radio" name="rbtn" value="2"> 2nd Choice</li>
 <li><input type="radio" name="rbtn" value="3"> 3rd Choice </li>
</ol>

Live Demo

name=foo

name=bar

  1. 1st Choice
  2. 2nd Choice
  3. 3rd Choice

name=”submit”

 


Firefox

Safari

Safari

Chrome

Opera

IE

Android

The Low Down

The name attribute defines the name of the form control, and is submitted along with the form control’s value when the form is submitted. It is the name part of the name/value pair associated with an element for the purposes of form submission.

  • The value of the name attribute can’t be an empty string, and should be unique, except in the case of radio and checkbox.
  • For radio, use the same name for all of the radio buttons in each group of radio buttons: only one radio button in a group of same named radio buttons can be selected at a time.
  • Though by no means required, you can give a group of checkboxes the same name, though each should have a different value.
  • Valid for all input types, and all other form controls. In addition to <button><textarea><select><form> and <input>, it is also valid on <iframe><object><map><param>, and <meta> tags.
  • When it comes to maps, the name attribute is how the <map> can be referenced.
  • The name attribute is required on <param>.
  • The name attribute on links and images is now obsolete. Use id instead.
  • The name attribute was also valid on applets and frames, which are now obsolete.

Our Cookie Policy and Privacy Policy outline how we use cookies to help optimize service, personalize content, tailor and measure our marketing, and improve your user experience. I agree to use of cookies for these purposes.