In this syntax, the id is a string that represents the id of the element to select. The id is case-sensitive. For example, the 'root' and 'Root' are totally different.
The id is unique within an HTML document. However, HTML is a forgiving language. If the HTML document has multiple elements with the same id, the document.getElementById() method returns the first element it encounters.
JavaScript getElementById() method example
Suppose you have the following HTML document:
<html><head><title>JavaScript getElementById() Method</title></head><body><pid="message">A paragraph</p></body></html>Code language: HTML, XML (xml)
The document contains a <p> element that has the id attribute with the value message: