Computer >> Computer tutorials >  >> Programming >> Javascript

What is the difference between id and name attributes in HTML?


ID

The ID of a form Element nothing to do just an identification and nothing to do with the data contained within the element. The IDs are attached in writing and using in Javascript and CSS.

Referened with JS method getElementByID()

Name

The NAME attribute is used in the HTTP request sent by browser to the server as a variable name and it is associated with the data contained in the value attribute. We 

Cannot be referenced in CSS or any URL

Referenced with JS method getElementByName()