-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
39 lines (26 loc) · 1 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
title: "Element: id property"
short-title: id
slug: Web/API/Element/id
page-type: web-api-instance-property
browser-compat: api.Element.id
---
{{ ApiRef("DOM") }}
The **`id`** property of the {{domxref("Element")}} interface
represents the element's identifier, reflecting the
[**`id`**](/en-US/docs/Web/HTML/Global_attributes/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 {{domxref("Document.getElementById()", "getElementById()")}} to retrieve a particular element.
Another common case is to use an element's [ID as a selector](/en-US/docs/Web/CSS/ID_selectors) when styling the document with [CSS](/en-US/docs/Web/CSS).
> **Note:** Identifiers are case-sensitive, but you should avoid creating
> IDs that differ only in the capitalization.
## Value
A string.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- The DOM [**id**](/en-US/docs/Web/HTML/Global_attributes/id)
global attribute.