auto

dir 属性 (HTML)

[1] HTML のほとんどの要素型で定義されている dir 属性は、 書字方向に関して中立な文 (固有方向性を有しない文) の基底方向を規定します。

仕様書

意味

[33] HTML のほとんどの要素型の要素の dir 属性は、書字方向中立文 (固有方向性を持たない文) の基底方向を定義します。 これは、要素の内容属性値に適用されます HTML 4.01 8.2, A.1.1.6

[32] bdo 要素の dir 属性は、他の要素の dir 属性と少し性質が違います。 bdo 要素の説明を参照してください。

[34] table 要素の dir 属性は、通常の意味に加えて、表の進行方向をも規定します。

[37] HTML 4.0 12.3.3 には link 要素で dir 属性を指定するとリンク先文書のことを記述しているように書かれていましたが、 誤りであるとして後に削除されました HTML 4.01 A.1.1.8。 正しくは link 要素でも他のほとんどの要素型と同じく、 属性値にだけ適用されます。 (link 要素は強制空要素なので、内容には適用のしようがありません。)

math 要素

[56] MathMLmath 要素dir 属性は、数式全体の方向性を指定します。 >>55

属性値

[2] この属性は列挙型です。

属性値意味
ltr左から右へ
rtl右から左へ

HTML 4 では、大文字・小文字を区別しません。 XHTML では、大文字・小文字を区別します。

HTML 4 や XHTML 1 のように DTD列挙型として定義されている版の HTML では、属性値表記内で実際の値の前後に空白を入れることができますが、 互換性のためにそうするべきではありません。

[22] XHTML m12n 仕様書の抽象モジュール定義に dir* ("ltr" | "rtl") とかいてある (属性名の後の * は必須を表す) けど、 DTD 実装と矛盾しているし、 誤植でしょうか?

既定値

[57] MathMLmath 要素では、既定値ltr です。これは、bidi 未対応だった MathML 2.0 以前との互換性のためです。 >>55

HTML もどき

[95] DTBookNCX にも HTML4 から移入されました。

レンダリング

[3] HTML 4 では、 Unicodebidi 算法に従うことになっています。 文書に右から左の文字を1文字も含まないときには HTML 4 適合 UA は必ずしもこの算法に従う必要はありませんが、 文書が右から左の文字を1文字でも含むなら、 HTML 4 適合 UA は Unicode bidi 算法に従わなければなりません。

Bidi 算法では著者の意図した通りの書字方向にならないときには、 適宜 dir 属性や bdo 要素を使って陽に方向を指定することができます。

なお、 HTML 4 仕様書によれば、 dir 属性をある要素に指定することは、 その前後に制御文字 LRERLEPDP を記述するのと同じことです。

[9] ちなみに、 HTML 4 は lang 属性で書字方向を決定することを禁じています。

[19] HTML 4 仕様書は、 著者および著述ソフトウェアの設計者に、 dir 属性と Unicode 文字による指定が衝突し得ることに注意を促しています。 意図しない結果となってしまわないように、どちらかの方法のみを使用するべきです (should) 。 どうしても両方を使用する必要があるときには、 適当に埋め込み・上書き (override) の関係が入れ子になるように気をつけるべきです (should) 。 そうでない場合のレンダリング結果は未定義です。

[42] 並び (ul, ol, dl) の記号数字・用語 (dt) をレンダリングする位置も方向性によって変わります。 左から右なら左側、右から左なら右側になります。 SI 4281:1998 9.3

属性値の継承

[4] ブロック水準要素dir 属性の値は、 bidi 算法でいうところの文ブロック基底文方向 (ブロック全体としての方向性) を指定するものです。

ブロック水準要素の dir 属性の値は、 上位のブロック水準要素の dir 属性の値を継承します。 最上位である html 要素に dir 属性が明示されていないときの既定値は ltr です。

[5] 一方、行内要素dir 属性の値は継承しません。 dir 属性が示された要素は、 bidi 算法的には新しい深さの埋め込み水準となります。

[6] HTML 4 仕様書 IW:HTML4:"struct/dirlang.html#blocklevel-bidi" によれば、ブロック水準要素・行内要素の区別は既定の表現によります。 つまり、たとえ CSSdisplay を変えるようなことをしても、 HTML の水準で行われる dir 属性の継承値決定には影響しないということです。 たぶんこれが、 HTML 4 が display 変更を非推奨としている理由でしょう。

[20] これに関して、 IW:HTML4:"struct/dirlang.html#style-bidi" には更に注意があります。 (便宜上 CSS の言葉を使って説明します。)

  • dir 属性を持たない ブロック水準要素display: inline としたときには、 dir 属性値を、 直近のブロック要素から継承します。
  • dir 属性を持たない行内要素を display: block としたときには、 dir 属性の継承値を陽に指定した場合と同じ結果が得られるべきです (should)

[7] HTML 的には属性の存在だけを提供して、 あとはスタイル言語に任せることにでもしておけばうまくいったかもしれませんけど、 CSS2HTML 4 の時間的関係を考えればやむを得ないと言うか何と言うか。 (スタイル言語によって異なる bidi 算法を採用していたりしたら面倒なことになりそうだよなぁ。)

[21] title 要素などではどう継承するのでしょう? 任意の要素の属性値ではどうなのでしょう?

>>7 スタイル言語によって異なる bidi 算法を採用していたりしたら、 そのスタイル言語のスタイル・シートで表示するときは HTML 4 不適合になるのだろうなあ (>>3)。

[27] IW:HTML4:"struct/tables.html#table-directionality" の説明によれば、 td はブロック水準要素型らしいです。 意味的に考えても、行内要素型以外はすべてブロック水準要素型と見なしてよいのではないでしょうか。 少なくても dir 属性の目的では。

[29] 表の中では %cellvalign と同じ継承規則が使われると HTML 4 では規定されています。

歴史

[31]

[50] XHTML2 の2つ目の作業原案で、前の原案にあった bdo 要素が廃止され、代わりに大域属性としての dir 属性に値 rlolro が追加されています。

[51] W3C 国際化中核作業部会は、自動推定することを表す値 auto を追加することを例示中でさり気なく提案しています。

MathML

[58] MathML 3.0math 要素に追加されました。

[10] english1 4WERBEH 3WERBEH 2WERBEH english5 のように表示されるべき段落があるとします。段落自体はラテン文字の英文ですから、 左から右に向かうべきですが、中にヘブライ文字で書かれた文を引用しています。 この部分は右から左に向かうべきです。

このとき、 HTML マーク付けとしては

のどれでも OK です。 (>>13 では q のタグを書いていません。 RLEPDPq 要素に含めるべきか否かよくわからないからです。 視覚的マーク付けと意味的マーク付けは相性が悪い。)

>>11 だけでも、 bidi 算法がヘブライ文字を見つけて右から左に向かうことを勝手に判断しますから、 普通は期待通りの結果が得られます。

[14] ここで、 english1 4WERBEH english3 2WERBEH english5 を考えます。ややこしいことに、 引用するヘブライ文字の文が更にラテン文字の英語を含んでしまっています。

>>15 はうまくいきません。 Bidi 算法はそもそも平文を想定しているので、 マーク付けによって木構造があっても特に取り計らってくれません。 HEBREW2HEBREW4 をそれぞれ別の埋め込み文とみなして、 english1 2WERBEH english3 4WERBEH english5 としてしまいます。

このように、2階層以上に左から右、右から左の入れ子関係があるときには、 >>16>>17 のように陽にこれを示さなければいけません。

[18] はっきりいってこの方式は駄目ですね。 折角の木構造を生かせていない。

[45] XHTML m12n では、双方向的文モジュールに、 このモジュールを選択すると I18n 属性集成dir が追加される、とあります。

これはわかりにくい。 Anne たんが見落とすのも無理はない。

しかも、dir* ("ltr" | "rtl") と名前の後に星印がついている。 つまり必須。それはおかしい。 (名無しさん 2006-08-06 05:24:05 +00:00)

[46] 'dir' attribute on BIDI inline elements and actual browsers from Helmut Wollmersdorfer on 2006-12-18 (www-html@w3.org from December 2006) http://lists.w3.org/Archives/Public/www-html/2006Dec/0017 (名無しさん 2006-12-20 23:30:41 +00:00)

[49] Denes Nad Makedonija - Wikipédia ( 版) http://fr.wikipedia.org/wiki/Denes_Nad_Makedonija

<span dir='ltr'><a href="/wiki/Cat%C3%A9gorie:Hymne_national" title="Cat&#233;gorie:Hymne national">Hymne national</a></span>
The document element also has the dir attribute specified with the value of ltr, therefore the dir attribute on the span element is redundant.

(名無しさん)

table 要素 dir 属性 (HTML, XHTML 1)

[26] HTMLtable 要素の dir 属性は、 >>1- の通常の役割に加えて、表の方向を決定します。

ltr なら表は左から右へ、 rtl なら右から左へ進みます。

table はブロック水準要素型なので、 >>4- の通り、既定値は上位要素からの継承です。

[36] 仕様書:

[27] 表が左から右に進むときは、最初の行は左側で、 次の行がその右に続きます。 右から左に進むときは、最初の行は右側で、次の行がその左に続きます。 どちらの場合も最初の列は上で、次の列が下に続きます。 HTML 4, SI 4281:1998 9.2

[41] このような効果があるのは、 table 要素だけです。 tbodytr は通常通りの働きしか持ちません。

なお、 thtddir 属性は、通常通りそのこま内のレンダリングを制御します。 両要素型はブロック水準要素型らしいので、上位の指定を継承します。

[30] 表の中では行だけではなく列からも継承します。 %cellvalign の説明をみてください。

メモ

bdo 要素 dir 属性 (HTML, XHTML 1)

[28] bdo 要素型の説明を参照してください。

:dir() 擬似クラス (選択子)

仕様書

意味

[65] :dir(ltr)方向性ltr であるすべての要素一致なければなりません >>64

[66] :dir(rtl)方向性rtl であるすべての要素一致なければなりません >>64

歴史

[68] 適用対象の要素HTML Living Standard で規定されています。

メモ

[43] Re: [Comment on its tagset WD] On (Bi)Directionality from Felix Sasaki on 2006-01-18 (www-i18n-comments@w3.org from January 2006) http://lists.w3.org/Archives/Public/www-i18n-comments/2006Jan/0003 (名無しさん 2006-01-28 02:48:57 +00:00)

[47] ISO/IEC 19757-3:2006 は dir 要素を定義しています。 value 属性があって、 ltr (から) または rtl (から) の自然言語文を表すとだけ規定されています。 (名無しさん)

[48] Internationalization Tag Set (ITS) Version 1.0 (2007-04-03 18:11:18 +09:00 版) http://www.w3.org/TR/2007/REC-its-20070403/#directionality (名無しさん)

[52] IRC logs: freenode / #whatwg / 20100824 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20100824#l-882

[53] Web Applications 1.0 r5579 Try to clarify that <title> directionality affects the use of the title outside the document.Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10817 ( ( 版)) http://html5.org/tools/web-apps-tracker?from=5578&to=5579

[54] Web Applications 1.0 r5672 Revamp how dir= is implemented; add dir=auto; update to recent CSS developments.Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10808]] ( ( 版)) http://html5.org/tools/web-apps-tracker?from=5671&to=5672

[59] Web Applications 1.0 r5886 Incomplete requirement text for <pre dir=auto> and <textarea dir=auta> (blocked on getting spec for white-space:plaintext) ( ( 版)) http://html5.org/tools/web-apps-tracker?from=5885&to=5886

[60] Web Applications 1.0 r5887 Update bidi requirements for <pre>, <textarea>, and <br>. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=5886&to=5887

[61] Web Applications 1.0 r6042 Make dir=auto isolate its contents for bidi purposes. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=6041&to=6042

[62] Web Applications 1.0 r6339 Add a note about why you would persist dir= in history traversal.]] ( ( 版)) http://html5.org/tools/web-apps-tracker?from=6338&to=6339

[63] Web Applications 1.0 r6420 fix dir=auto for <textarea> and <input> text fields. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=6419&to=6420

[69] Web Applications 1.0 r6942 The 'bidi-override:embed' rule for [dir] shouldn't take effect for block-level elements (since it overrides their 'isolate' rule).Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=14850 ( ( 版)) http://html5.org/tools/web-apps-tracker?from=6941&to=6942

[70] Web Applications 1.0 r7043 Only apply styles for [dir] if the attribute value is actually valid (ltr, rtl, auto). ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7042&to=7043

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

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

[73] Web Applications 1.0 r7799 Let human-readable attributes honour dir=auto separately from the element's contents. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7798&to=7799

[74] Web Applications 1.0 r7805 Make dir=auto inherit when the element has no obvious directionality. (Except for <bdi>, which still defaults to ltr.) ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7804&to=7805

[75] Web Applications 1.0 r7863 Work on dir=auto. More work may come. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7862&to=7863

[76] Web Applications 1.0 r7887 Shouldn't force-set 'direction' on every element, only those that mention dir=.]] ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7886&to=7887

[77] Web Applications 1.0 r7955 Another attempt at making directionality in various edge cases more useful and more intuitive. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7954&to=7955

[78] Web Applications 1.0 r8033 Hopefully final fix for automatic directionality. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=8032&to=8033

[79] Web Applications 1.0 r8283 Change how dir= works, from being an embedding to being an override, for better results on mixed-directionality sites. THIS IS A HIGH RISK CHANGE, EXPECT BREAKAGE. Please report breakage on the bug if it's higher than acceptable, so we can revert the change if necessary.]] ( ( 版)) http://html5.org/tools/web-apps-tracker?from=8282&to=8283

[80] Web Applications 1.0 r8317 Move all requirements about bidi out and just rely on CSS instead. Also, fix the CSS rules for <bdo>. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=8316&to=8317

[81] ncsa-mosaic/CHANGES at master · alandipert/ncsa-mosaic ( ( 版)) https://github.com/alandipert/ncsa-mosaic/blob/master/CHANGES#L1231

[82] Internationalization Tag Set (ITS) Version 1.0 ( ( 版)) http://www.w3.org/TR/its/#directionality

[83] Internationalization Tag Set (ITS) Version 2.0 ( ( 版)) http://www.w3.org/TR/its20/#high-level-differences-between-1.0-and-2.0

[84] Internationalization Tag Set (ITS) Version 2.0 ( ( 版)) http://www.w3.org/TR/its20/#directionality

[85] Authoring HTML: Handling Right-to-left Scripts ( ( 版)) http://www.w3.org/TR/2014/NOTE-i18n-html-tech-bidi-20140603/

[86] Web Applications 1.0 r8695 Catch up with recent changes that were made while the pipeline was down. Sorry for jamming all these changes into one patch. ( ( 版)) http://html5.org/r/8695

[8] Packaged Web Apps (Widgets) - Packaging and XML Configuration (Second Edition) ( 版) http://w3c.github.io/packaged-webapps/packaging/#the-dir-attribute

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

[24] Formalize custom element reactions · whatwg/html@27aa7bc ( 版) https://github.com/whatwg/html/commit/27aa7bc4fa6f168654a8c858f0773e611f679b39

[25] Web Annotation Data Model () https://w3c.github.io/web-annotation/model/wd2/#h-external-web-resources

textDirection Relationship The overall base direction of the text in the resource.

The Body or Target may have exactly 1 textDirection associated with it. The value of the property must be one of the directions defined below (ltr, rtl, or auto).

[35] Web Annotation Data Model () https://w3c.github.io/web-annotation/model/wd2/#h-external-web-resources

The notion of text direction and the definitions of auto, ltr and rtl values are taken explicitly from the HTML5 [html5] dir attribute.

[38] Web Annotation Vocabulary () https://w3c.github.io/web-annotation/vocab/wd/#h-direction

[39] Web Annotation Vocabulary () https://w3c.github.io/web-annotation/vocab/wd/#h-textdirection

[40] Schematron: dir 要素があって、 value 属性ltr または rtl

[44] Notes on JSON strings and text direction () https://w3c.github.io/i18n-discuss/notes/json-bidi

[87] XLIFF Version 2.0 () http://docs.oasis-open.org/xliff/xliff-core/v2.0/os/xliff-core-v2.0-os.html#dir

[88] XLIFF Version 2.0 () http://docs.oasis-open.org/xliff/xliff-core/v2.0/os/xliff-core-v2.0-os.html#dir

[89] draft-snell-atompub-bidi-08 - Atom Bidirectional Attribute () https://tools.ietf.org/html/draft-snell-atompub-bidi-08

[90] [selectors-4] Link to ITS (as an example) from :dir(). Fixes #2238. (fantasai著, ) https://github.com/w3c/csswg-drafts/commit/86f2a688be7a32bcb0c4f90013ee0ea26d45c2c0

[91] [selectors-4] Add its:dir as an example of markup mapping to :dir() · Issue #2238 · w3c/csswg-drafts () https://github.com/w3c/csswg-drafts/issues/2238

[92] Editorial: always state invalid value default (GloverDonovan著, ) https://github.com/whatwg/html/commit/7e941ae96b264d4743ea0afac00c3b3209ab0cde

[93] [selectors-4] Link to ITS (as an example) from :dir(). Fixes #2238. (fantasai著, ) https://github.com/w3c/csswg-drafts/commit/86f2a688be7a32bcb0c4f90013ee0ea26d45c2c0

[94] [selectors-4] Add its:dir as an example of markup mapping to :dir() · Issue #2238 · w3c/csswg-drafts () https://github.com/w3c/csswg-drafts/issues/2238