Element: id property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Theid property of theElement interfacerepresents the element's identifier, reflecting theidglobal attribute.
If theid value is not the empty string, it must be unique in a document.
Theid is often used withgetElementById() to retrieve a particular element.Another common case is to use an element'sID as a selector when styling the document withCSS.
Note:Identifiers are case-sensitive, but you should avoid creatingIDs that differ only in the capitalization.
In this article
Value
A string.
Specifications
| Specification |
|---|
| DOM> # ref-for-dom-element-id①> |
Browser compatibility
See also
- The DOMidglobal attribute.