Element.id
The id
property of the Element
interface
represents the element's identifier, reflecting the
id
global attribute.
If the id
value is not the empty string, it must be unique in a document.
The id
is often used with getElementById()
to retrieve a particular element. Another common case is to use an
element's ID as a selector when styling
the document with CSS.
Note: Identifiers are case-sensitive, but you should avoid creating IDs that differ only in the capitalization.
Value
A string.
Specifications
Specification |
---|
DOM Standard # ref-for-dom-element-id① |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
id | ChromeFull support23 | EdgeFull support12 | FirefoxFull support1 | Internet ExplorerFull support5 | OperaFull support12.1 | SafariFull support1 | WebView AndroidFull support37 | Chrome AndroidFull support25 | Firefox for AndroidFull support4 | Opera AndroidFull support12.1 | Safari on iOSFull support1 | Samsung InternetFull support1.5 |
Legend
- Full support
- Full support
- Partial support
- Partial support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
See also
- The DOM id global attribute.