The difference between Id and Name in HTML is in html: name refers to the user Name, ID refers to the user registration is a serial number automatically assigned to the user. Name is used to submit data. It is provided to the form and can be repeated. id is used for document operations and cannot be repeated. For example, document. getElementById (); 1. ID is used in the client script! NAME is used to obtain information about a form field of the submitted form. In the form, if Name is not specified, it will not be sent to the server. Ii. Names are used for the following elements: input, select, form, frame, and iframe, while IDs are used for the following elements: table, tr, td, div, p, span, h1, and li, form input textarea select and iframe frame use name. These elements are related to the form (the frame element acts on the target of the form) submission, only the element with name is received on the form receiving page, and the element with ID is not received through the form. of course, the above elements can also be assigned an ID value. The method for referencing these elements when assigning an ID value will be changed. name: document. formName. inputName document. frames ("frameName") assigned ID: document. all. inputID document. all. frameID can only be an element with an ID but not a name: (only the elements related to the form can be assigned an ID.) B Ody li a table tr td th p div span pre dl dt dd font B. For example, <form name = "form1"> User name: <input type = text name = "username" id = "username"> password: <input type = password name = "password" id = "pwd"> </form> if I want to obtain the user name and password, and JS uses the name, I have to write it as document. form1.username. value; document. form1.password. value; obtained by id: docuement. getElementById ("username"); docuement. getElementById ("pwd"); sometimes the same name may appear in the name, so we cannot get it using the name. Determine which value is obtained. Document. getElemntsByName ("username"); here we get an array document. getElementsByName (xxx); The retrieved array document. getElementById (xxx ); some elements need to be paid attention to when retrieving a single object. For example, you can use the id name of the div to directly obtain the object <div id = "div1"> </div> div1.innerHTML = "asdfasdf "; the form element cannot be like this. You can only use document. getElementById (xx)