The id
attribute is supposed to be unique in your document. Only one element can have a given id. document.getElementById()
finds the first element with the given id
.
The name
attribute is used by forms as the key in a key/value pair when submitting the form. The value
attribute is both displayed in the browser, and submitted with the form.
Neither is "more important," they're just different. If you have an XML mindset, they're both just attributes on a node. In HTML they have more meaning though.