3 Replies - 929 Views - Last Post: 22 April 2009 - 06:11 PM

#1 kahled  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-March 09

html name/id

Post icon  Posted 21 April 2009 - 05:06 PM

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
Is This A Good Question/Topic? 0
  • +

Replies To: html name/id

#2 sl4ck3r  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 11
  • View blog
  • Posts: 285
  • Joined: 22-September 07

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

Was This Post Helpful? 0
  • +
  • -

#3 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1201
  • View blog
  • Posts: 7,309
  • Joined: 07-September 06

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
$_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 :)
Was This Post Helpful? 1
  • +
  • -

#4 crazyjugglerdrummer  Icon User is offline

  • GAME OVER. NERD WINS.
  • member icon

Reputation: 119
  • View blog
  • Posts: 690
  • Joined: 07-January 09

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. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1