شناسه
id
global attribute (صفت سراسری id
) شناسه (ID) ایست که باید در تمام سند بیهمتا باشد. هدف آن شناسایی عنصری خاص به هنگام پیوند دادن (با استفاده از شناسهی تکه)، اسکریپتنویسی، یا طراحی ( با CSS) است.The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
مقدار این صفت یک رشتهی مبهم است، به این معنی که نویسندگان وب نباید از آن برای رساندن اطلاعاتی که برای انسان قابل خواندن است استفاده کنند.
مقدار id
نباید حاوی whitespace (فاصلهها، تبها و مانند آن) باشد. در شناسه هایی که حاوی فاصلهی سفید (whitespace) هستند، مرورگرها فاصلهی سفید را بخشی از شناسه در نظر میگیرند. برخلاف صفت class
، که مقادیر جداشده با فاصله را مجاز میداند، عنصرها تنها میتوانند یک مقدار شناسه داشته باشند.
مشخصات
مشخصه | وضعیت | توضیح |
---|---|---|
HTML Living Standard The definition of 'id' in that specification. |
Living Standard | No change from latest snapshot, HTML 5.1 |
HTML 5.1 The definition of 'id' in that specification. |
Recommendation | Snapshot of HTML Living Standard, no change from HTML5 |
HTML5 The definition of 'id' in that specification. |
Recommendation | Snapshot of HTML Living Standard, now accept '_' , '-' and '.' if not at the beginning of the id. It is also a true global attribute. |
HTML 4.01 Specification The definition of 'id' in that specification. |
Recommendation | Supported on all elements but <base> (en-US), <head> (en-US), <html> (en-US), <meta> (en-US), <script> (en-US), <style> (en-US), and <title> (en-US). |
سازگاری مرورگر
BCD tables only load in the browser
همچنین ببینید
- .همهی صفتهای سراسری
Element.id
(en-US) که بازتاب کنندهی این صفت است.