[thelist] ID= vs NAME=

aardvark roselli at earthlink.net
Fri Sep 8 11:08:37 CDT 2000


> From: Gregory.John.Toland at census.gov
> 
> What is the difference between these two attributes.  Do you always
> declare both?  Is one strictly used for IE and the other for NN?  What
> are the implications?

'name' is an old attribute... 'name' was used to get rollovers to 
work, and is given to form fields to assign their name... 'name' is 
used by <meta>, <a>, <map>, <frame>, etc., but that may not be 
why you are asking, you probably want to know in regard to its use 
with JS or forms...

'id' is supposed to take its place in many cases... 'id' can be 
referenced by CSS, HTML4 form accessibility options, and JS... 
however, not all browsers recognize 'id'... 'id' can be used in all but 
a few tags (like <meta>, <html>, etc.)...

so, until this whole mess is straightened out, all my form fields 
have an 'id' attribute that matches the 'name', except for radio 
buttons and checkboxes, where the 'id' is used by the <label> 
tag... this way i can still call CSS on it and use HTML4 
accessibility features...

how are you using it?

the best way to determine if your use is correct is to check out the 
HTML4 elements page at:
http://www.w3.org/TR/html4/index/attributes.html
there it offers links to the attributes, their uses, if they are 
deprecated, etc...

i still use 'name' for images in rollovers, and may continue to do 
that for a while until i more thoroughly understand the implications 
of its use and the use of 'id' through testing...

remember that you can only use an 'id' once, so trying to assign 
the same 'id' to multiple elements to apply some CSS is wrong, 
and you should use 'class' instead...




More information about the thelist mailing list