Element: id property
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{ ApiRef("DOM") }}
The **id** property of the {{domxref("Element")}} interface reflects the element's [id](/en-US/docs/Web/HTML/Reference/Global_attributes/id) content 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 when styling the document with CSS.
توجه: 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
global attribute.