MDN will switch to a new design later today, a sneak peek: Redirect 1

« DOM Reference


name gets or sets the name propery of a DOM object; it only applies to the following elements: <a>, <applet>, <button>, <form>, <frame>, <iframe>, <img>, <input>, <map>, <meta>, <object>, <param>, <select>, and <textarea>.

Note that the name property doesn't exist on the other element. It is not a property of the Element or HTMLElement interface.

Name can be used in the document.getElementsByName() method, a form and with the form elements collection. When used with a form or elements collection, it may return a single element or a collection.

Syntax = string;
var elName =;

var fControl = HTMLFormElement.elementName;
var controlCollection = HTMLFormElement.elements.elementName;


<form action="" name="formA">
  <input type="text" value="foo">

<script type="text/javascript">

  // Get a reference to the first element in the form
  var formElement = document.forms['formA'].elements[0];

  // Give it a name = 'inputA';

  // Show the value of the input


In Internet Explorer (IE), the name property of DOM objects created using document.createElement() can't be set or modified.


W3C DOM 2 HTML Specification:

Document Tags and Contributors

 Last updated by: Sheppy,