id属性

id 属性 (HTML)

[2] id 属性は、要素識別子を割り当てるものです。

id 属性 (HTML, XHTML 1)

[9] id 属性は、 HTML のほとんどの要素型で定義されています。 この属性は、要素名前を割り当てます。 名前は文書内で固有である必要があります。

仕様書:

[10] 仕様書 IW:HTML4:"struct/global.html#id-and-class" では、この属性の値の役割として、

を挙げています。

属性値

[13] この属性は、 HTML 4 的には name 型、 SGML/XML 的には ID 型です。

[4] HTMLid 属性値の取りうる値:

詳しくは噂のID問題をご覧下さい。

[14] この属性の値の名前空間は a 要素の name 属性と共有しています。

[15] この属性は省略可能です。省略時は ID なしになります。

大文字と小文字

[11] (HTML は、大文字・小文字を区別しない(たぶん)。) (XHTML は、大文字・小文字を区別する。)

[1] >>11 HTML でも大文字・小文字が区別されるという話がありますが、どうなんでしょう?

[5] >>1 IETF/W3C HTML の SGML宣言によれば、 名前の大文字と小文字は区別されません。 (大文字に正規化されます。) 実装には区別するものもきっとあるんでしょうが。。。

[12] >>11,>>1,>>5 この問題 (通称噂のID問題) は非常に難しい状態にあることがわかっています。 詳しくは噂のID問題の頁をごらんください。

実装

[7] NC は (少なくても 4.01 は) id 属性に対応していません。

[16] 終点アンカーとしての使用例

You may read more about this in <A href="#SECTION2">Section Two</A>.
...later in the document
<H2 id="SECTION2">Section Two</H2>
...later in the document
<P>Please refer to <A href="#SECTION2">Section Two</A> above
for more details.

(HTML 4 仕様書より、改)

[17] 終点アンカーとしたいときで、適切な要素がないときには、 a 要素が使えます。

I just returned from vacation! Here's a
<A id="ANCHOR-TWO">photo of my family at the lake.</A>.

(HTML 4 仕様書より、改)

[20] CSS で特定の要素のスタイルを指定する例

<HEAD>
 <TITLE>CSS and ID Example</TITLE>
 <STYLE type="text/css">
   #MYID {border-width: 1px; border: solid; text-align: center}
 </STYLE>
</HEAD>
<BODY>
 <H1> This H1 is not affected </H1>
 <H1 id="MYID"> This H1 is affected by style </H1>
 <H1> This H1 is not affected </H1>
</BODY>

(HTML 4 仕様書より、改)

[49] ロイター.co.jp | ロイターe調査, 投票, 調査, ビジネス, 海外, 経済, 金融, ニュース (2008-09-02 09:57:11 +09:00 版) http://polls.reuters.com/jp/1220280342250 (text/html)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head> 
  <title>ロイター.co.jp | ロイターe調査, 投票, 調査, ビジネス, 海外, 経済, 金融, ニュース</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta id="MetaDescription" name="description" content="Reuters.co.jpはニュース速報、ワールドニュース、ビジネス情報、経済ニュース、株式ニュース、外国為替ニュースなどが入手できる重要な情報源です。ロイターは世界中のメディア、金融機関、そして個人投資家にニュースや金融情報、テクノロジーを提供する世界最大の国際通信社です。"></meta>
  <meta id="MetaKeywords" name="keywords" content="ロイター ニュース ロイター通信 国際ビジネスニュース IT・インターネットニュース 海外株式情報 ワールドカップ"></meta>

(名無しさん)

メモ

[18] HTML 4 仕様書には id 属性の属性値指定文字参照が使えないようなことが書かれていますが、 これは誤りで、属性値表記なら使うことができます。 実体参照ももちろん使えます。 例: <a id="D&Uuml;RST">Martin D&uuml;rst</a>

[19] >>18 id は名前ですから、HTML 4 で &Uuml; などの文字を含むことはできません (例えば id="D&#85;ERST" なら可能ですが)。

なお、XHTML では名前文字の範囲が広がっていますので、id="D&Uuml;RST" も valid です。

[33] 2006-07-02 - d:id:quaa (2007-10-17 02:34:07 +09:00 版) http://d.hatena.ne.jp/quaa/20060702#p3 (名無しさん)

[34] 2006-07-02 - d:id:quaa (2007-10-17 02:34:07 +09:00 版) http://d.hatena.ne.jp/quaa/20060702#p3 (名無しさん)

[35] 誤り訂正日記 - d:id:quaa (2007-11-11 11:17:03 +09:00 版) http://d.hatena.ne.jp/quaa/20071108#p2 (名無しさん)

[36] ID属性値を巡るhCalendarの奇妙な冒険 | hemiolia.com (kotarok 著, 2008-02-10 00:17:14 +09:00 版) http://hemiolia.com/blog/200802/000142

id 属性 (MathML)

[67] MathMLの大域属性である id 属性は、 リンク相互参照並列マーク付けのための固有識別子を指定するものです >>68

仕様書

構文

[69] id 属性値の構文は id です >>68

id 属性 (XML 型録)

[6] XML 型録の要素型 (名前空間名urn:oasis:names:tc:entity:xmlns:xml:catalog 及び urn:oasis:names:tc:entity:xmlns:tr9401:catalog の全ての要素型) には id 属性 (型 = ID) が存在します。

この属性は型録的には意味が無く、単に識別のためだけにあります。 省略可能です。 http://www.oasis-open.org/committees/entity/spec.html#attrib.common

HTML 以外

[65] DTBook / NCX にも HTML4 から移入されました。

id 属性 (SMIL)

[56] SMIL のほとんど (すべて?) の要素id 属性は、 文書中で要素を特定する固有識別子です。

要素
SMIL要素
属性名
id
データ型
XML ID
既定値
(なし)

仕様書:

xml:id 属性 (XML)

[42] xml:id を参照。

メモ

[3] xsl:keyを使おう(1) http://www.yuragi.jp/playxslt/p003.asp: XPathid() 関数について。

[23] How to make a good ID in Atom [dive into mark] http://diveintomark.org/archives/2004/05/28/howto-atom-id

[28] hatena::get_diary<gnarl>::result - Operaとfirefoxでxpathの挙動が違うよ!誰のせい?誰のせい? (2007-06-04 18:28:13 +09:00 版) http://d.hatena.ne.jp/gnarl/20070602/1180782611 (名無しさん 2007-06-09 14:02:24 +00:00)

[29] d:id:quaa (2007-06-07 22:15:24 +09:00 版) http://d.hatena.ne.jp/quaa/20070607#p1 (名無しさん 2007-06-09 14:02:48 +00:00)

[30] *DRAFT* W3 Forms F2F (Hawthorne) Day 1 June 13, 2007 (2007-06-26 18:29:00 +09:00 版) http://lists.w3.org/Archives/Public/public-forms/2007Jun/att-0034/2007jun13.html#topic15.1 (名無しさん)

[31] DOM といい XPath といい ID 要素は完全になかったことに? (名無しさん)

[32] d:id:quaa (2007-08-06 19:32:28 +09:00 版) http://d.hatena.ne.jp/quaa/20070806#p1

[74] Web Applications 1.0 r6605 move .id and ID processing to DOM Core. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=6604&to=6605

[75] Packaged Web Apps (Widgets) - Packaging and XML Configuration (Second Edition) ( ( 版)) http://w3c.github.com/packed-webapps/packaging/#the-id-attribute

[78] WOFF File Format 1.0 ( ( 版)) http://www.w3.org/TR/2012/REC-WOFF-20121213/#Metadata

[79] Document Object Model for MathML ( ( 版)) http://www.w3.org/TR/2001/REC-MathML2-20010221/appendixd.html#dom_Element

[80] Document Object Model for MathML ( ( 版)) http://www.w3.org/Math/DOM/mathml2/appendixd.html#dom_Element

[83] XML Binding Language (XBL) 2.0 ( ( 版)) http://www.w3.org/TR/2007/CR-xbl-20070316/#the-id

[85] OMDoc ( 版) http://omdoc.org/pubs/omdoc1.2.pdf#page=106

[86] XPath and XQuery Functions and Operators 3.0 ( ( 版)) http://www.w3.org/TR/xpath-functions-3/#func-id

[8] Editorial: synchronize with the DOM Standard · whatwg/html@21c6ec7 ( 版) https://github.com/whatwg/html/commit/21c6ec77594eb89b836d4872222f5916910967fd

[21] Shadow: define superglobal slot content attribute · whatwg/dom@e3d8291 ( 版) https://github.com/whatwg/dom/commit/e3d82914676ad1e1bf590e1042636e60feddb6ae

[22] The DOM Standard defines the class, id, and slot attributes · whatwg/html@36c9938 ( 版) https://github.com/whatwg/html/commit/36c9938b102fecadf6029a248f40aae83ea099d2

[24] Id attribute: harmonize requirements with HTML, add warning about XML… (AmeliaBR著, ) https://github.com/w3c/svgwg/commit/09a1a0a1f5cc3dd2fa785bf23f309cb906027299

[25] AMP HTML Specification – AMP () https://www.ampproject.org/docs/reference/spec

Internal AMP IDs prefixed with -amp- and i-amp- are disallowed in AMP HTML.

Consult AMP documentation for specific extensions before using amp- and AMP IDs to avoid conflict with the features provided by these extensions, such as amp-access.

All other authored IDs are allowed in AMP HTML markup.