The HTML id Attribute
id="name" assigns a unique name to an HTML element. This is useful when the element has to be manipulated using JavaScript, or accessed(scrolled to), from another location on the same page. W3C specifications dictate that element ids should be unique - i.e. no two elements in a document should have the same id. In practice, browsers don't complain when they encounter repeated ids. However, attempting to retrieve an element in JavaScript using the document.getElementById method always returns the first matching element.
▼Jump To...