Form <inpu> name & id required?

C

Caversham

I notice that Dreamweaver automatically adds both name and id
attributes to form input tags. Are both of these required? Is there
some recommendation both should be used?

Caversham
 
L

Lachlan Hunt

Caversham said:
I notice that Dreamweaver automatically adds both name and id
attributes to form input tags. Are both of these required? Is there
some recommendation both should be used?

The name attribute is used when submitting the name=value pairs. The id
attribute is useful for referencing from other places, such as with the
for attribute in the label element, with scripts by using
getElementById(), with stylesheets using the ID selector, etc. Neither
of them are required.
 
J

Jonathan N. Little

Caversham said:
I notice that Dreamweaver automatically adds both name and id
attributes to form input tags. Are both of these required? Is there
some recommendation both should be used?

Caversham
name is for backward compatibility with legacy browsers, like NN4x.
 
M

Mitja

name is for backward compatibility with legacy browsers, like NN4x.
Not for form elements. Try
<form ...>
<input type="text" id="foo" value="bar"> <input type="submit">
</form>
and see if it works :)
ID and name have different semantics and uses, like Lachlan explained.
 
R

RobG

Mitja said:
Not for form elements. Try
<form ...>
<input type="text" id="foo" value="bar"> <input type="submit">
</form>
and see if it works :)
ID and name have different semantics and uses, like Lachlan explained.

Input & name:
<URL:http://www.w3.org/TR/html4/interact/forms.html#adef-name-INPUT>
<URL:http://www.w3.org/TR/html4/interact/forms.html#control-name>

ID:
<URL:http://www.w3.org/TR/html4/struct/global.html#adef-id>

HTML attributes:
<URL:http://www.w3.org/TR/html4/index/attributes.html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top