HTML form name Attribute

Definition and Usage

The name attribute is an identification for the form. In XHTML this has been replaced with the id attribute.


<form name="name_id">

Syntax Example

<form name="default_form">

Attribute Values

Value Description
name_id The name/identifier of the form.Naming rules:
  • Must begin with a letter A-Z or a-z
  • Can be followed by: letters (A-Za-z), digits (0-9), hyphens ("-"), underscores ("_"), colons (":"), and periods (".")
  • Values are case-sensitive

Browser Support

The attribute is supported in all major browsers.

The difference of name and id

HTML 4.01 defines a name attribute for the elements a, applet, form, frame, iframe, img, and map. The name attribute is used for backwards compatibility. In XHTML the name attribute is deprecated. Use id instead.

This is wrong:
<form action="form_example.asp" name="default"> 

This is correct:
<form action="form_example.asp" id="default">

Note: To interoperate with older browsers for a while, you should use both name and id, with identical attribute values, like this:

<form action="form_example.asp" id="default" 


<form action="demo_form_name.asp" id="demoform"
First name: 
<input type="text" name="FirstName"
 value="Harry" />
<br />
Last name: 
<input type="text" name="LastName" 
value="Potter" />
<br />
<input type="submit" value="Submit" />
HTML form name Attribute Reviewed by 1000sourcecodes on 03:48 Rating: 5
Powered by Blogger.