Definition and Usage The name attribute is an identification for the form. In XHTML this has been replaced with the id attribute. Syntax ...
Definition and Usage
The name attribute is an identification for the form. In XHTML this has been replaced with the id attribute.
Syntax
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" name="default"> |
Example
<form action="demo_form_name.asp" id="demoform" name="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" />
</form> |