HTML elements can have a "name" and/or an "id" identifier.
1)What is the difference between these two identifiers?
2)and when is it relevant to use "id" and not "name" or vice versa?
Thanks in advance
html name/id
Page 1 of 13 Replies - 763 Views - Last Post: 22 April 2009 - 06:11 PM
Replies To: html name/id
#2
Re: html name/id
Posted 21 April 2009 - 05:12 PM
id are used by Javascript and also by css, it is suppose to be unique in css. classes are non unique for css. i dont really useeeeeee names. hope this helps
This post has been edited by sl4ck3r: 21 April 2009 - 05:15 PM
#3
Re: html name/id
Posted 21 April 2009 - 05:16 PM
Id is used by either Javascript and/ or CSS, and must be unique between tags for it to have any effect (though CSS will allow multiple tags to have the same ID (I believe)), classes are used by CSS to give things a style.
Names are used when submitting forms to a server side script. The only way the server can identify what fields are in the form is based on the names used in the form.
For instance if you had an input text with the name "test" PHP could get to the submitted data through
Javascript can use names but it is better practice (and less buggy) to simply use IDs.
Hope that helps
Names are used when submitting forms to a server side script. The only way the server can identify what fields are in the form is based on the names used in the form.
For instance if you had an input text with the name "test" PHP could get to the submitted data through
$_POST['test']. Granted this requires that the form is submitted to the correct .php page (requires page refresh and PHP support on servers).
Javascript can use names but it is better practice (and less buggy) to simply use IDs.
Hope that helps
#4
Re: html name/id
Posted 22 April 2009 - 06:11 PM
id is the answer to the deprecated name attribute. Name is still used in form submissions to refer to a specific element, but other than that its old school.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|