Element: id プロパティ
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.
id
は Element
インターフェイスのプロパティで、グローバル属性の id
を反映した要素の識別子を表します。
id
の値が空文字列でない場合は、文書内で固有でなければなりません。
id
はよく getElementById()
で特定の要素を受け取るために使用します。他の一般的な用途としては、要素の ID をセレクターとして CSS で文書をスタイル付けするために使用されます。
メモ: 識別子は大文字小文字の区別がありますが、大文字小文字の区別だけで見分ける ID を作ることは避けてください。
値
文字列です。
仕様書
Specification |
---|
DOM # ref-for-dom-element-id① |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial support
- Has more compatibility info.
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.
関連情報
- DOM の id グローバル属性