Difference between "name" and "id"

Discussion in 'JavaScript' started by enchance, Oct 8, 2007.

  1. #1
    I have always wondered about this one. I use "id" with CSS and "name" with forms but is that really why these 2 are separate? What is it about them that they had to be separated?
     
    enchance, Oct 8, 2007 IP
  2. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #2
    I think name was introduced by IE browsers, and id is the W3C standard.
    Usually is a good idea to use both on same element, to achieve cross-browser compatible code. Example:
    <form name="myform" id="myform">...</form>
     
    ajsa52, Oct 12, 2007 IP