Living Standard — Last Updated 3 June 2023
details
要素summary
要素a
element to define a commandbutton
element to define a commandinput
element to define a commandoption
element to define a commandaccesskey
attribute on a legend
element to define a commandaccesskey
attribute to define a command on other elementsdialog
要素details
要素Support in all current engines.
Support in all current engines.
summary
要素に続くフローコンテンツ。open
— detailsが可視かどうか[Exposed =Window ]
interface HTMLDetailsElement : HTMLElement {
[HTMLConstructor ] constructor ();
[CEReactions ] attribute boolean open ;
};
details
要素は、ユーザーが追加情報やコントロールを得ることができるディスクロージャーウィジェットを表す。
details
要素は、脚注には適さない。脚注をマークアップする方法の詳細については、脚注のセクションを参照のこと。
要素の子である最初のsummary
要素がもしあれば、detailsの要約または凡例を表す。If there is no child summary
element, the user agent should provide its own legend (e.g. "Details").
要素のコンテンツの残り部分は、追加情報やコントロールを表す。
open
コンテンツ属性は、真偽属性である。存在する場合、この属性は要約と追加情報の両方がユーザーに表示されることを示す。属性が存在しない場合、要約のみが表示されるようになる。
When the element is created, if the attribute is absent, the additional information should be hidden; if the attribute is present, that information should be shown. Subsequently, if the attribute is removed, then the information should be hidden; if the attribute is added, the information should be shown.
The user agent should allow the user to request that the additional information be shown or hidden. To honor a request for the details to be shown, the user agent must set the open
attribute on the element to the empty string. To honor a request for the information to be hidden, the user agent must remove the open
attribute from the element.
This ability to request that additional information be shown or hidden may simply be the activation behavior of the appropriate summary
element, in the case such an element exists. However, if no such element exists, user agents can still provide this ability through some other user interface affordance.
Whenever the open
attribute is added to or removed from a details
element, the user agent must queue an element task on the DOM manipulation task source given then details
element that runs the following steps, which are known as the details notification task steps, for this details
element:
If another task has been queued to run the details notification task steps for this details
element, then return.
When the open
attribute is toggled several times in succession, these steps essentially get coalesced so that only one event is fired.
Fire an event named toggle
at the details
element.
Support in all current engines.
open
IDL属性は、open
コンテンツ属性を反映しなければならない。
The ancestor details revealing algorithm is to run the following steps on currentNode:
While currentNode has a parent node within the flat tree:
次の例は、details
要素が進捗報告書で技術的な詳細を非表示にするために使用される様子を示す。
< section class = "progress window" >
< h1 > Copying "Really Achieving Your Childhood Dreams"</ h1 >
< details >
< summary > Copying... < progress max = "375505392" value = "97543282" ></ progress > 25%</ summary >
< dl >
< dt > Transfer rate:</ dt > < dd > 452KB/s</ dd >
< dt > Local filename:</ dt > < dd > /home/rpausch/raycd.m4v</ dd >
< dt > Remote filename:</ dt > < dd > /var/www/lectures/raycd.m4v</ dd >
< dt > Duration:</ dt > < dd > 01:16:27</ dd >
< dt > Color profile:</ dt > < dd > SD (6-1-6)</ dd >
< dt > Dimensions:</ dt > < dd > 320×240</ dd >
</ dl >
</ details >
</ section >
以下は、details
要素がデフォルトで一部のコントロールを非表示にするために使用できる様子を示す:
< details >
< summary >< label for = fn > Name & Extension:</ label ></ summary >
< p >< input type = text id = fn name = fn value = "Pillar Magazine.pdf" >
< p >< label >< input type = checkbox name = ext checked > Hide extension</ label >
</ details >
これは、ユーザーがそれぞれを開くことができる機能とともに、見出しの小さな集合にフィールドの集合を折りたたむことができるよう、リスト内の他のdetails
とともにこれを使用できる。
これらの例において、要約はコントロールが変更できるものをまとめたものであり、理想に満たない実際値ではない。
ユーザーがコントロールを操作するために自動的にopen
属性が追加および削除されるので、この属性の状態に基づく異なる、この属性CSSで要素に使用できる。ここでは、スタイルシートを使用して、要素を開いたり閉じたりしたときのsummaryの色をアニメーションさせている:
< style >
details > summary { transition : color 1 s ; color : black ; }
details [ open ] > summary { color : red ; }
</ style >
< details >
< summary > Automated Status: Operational</ summary >
< p > Velocity: 12m/s</ p >
< p > Direction: North</ p >
</ details >
summary
要素Support in all current engines.
details
要素の最初の子として。HTMLElement
を使用する。summary
要素は、もしあれば、summary
要素の親details
要素に属する残りの内容のキャプションまたは凡例を表す。
A summary
element is a summary for its parent details if the following algorithm returns true:
If this summary
element has no parent, then return false.
Let parent be this summary
element's parent.
If parent is not a details
element, then return false.
If parent's first summary
element child is not this summary
element, then return false.
Return true.
The activation behavior of summary
elements is to run the following steps:
If this summary
element is not the summary for its parent details, then return.
Let parent be this summary
element's parent.
If the open
attribute is present on parent, then remove it. Otherwise, set parent's open
attribute to the empty string.
This will then run the details notification task steps.
コマンドは、メニュー項目、ボタン、リンクの背後に抽象化したものである。一度コマンドが定義されると、インターフェイスの他の部分は、Disabled状態のようなファセットを共有するために単一の機能へ多くのアクセスポイントを許可し、同じコマンドを参照できる。
コマンドは、次のファセットを持つように定義される:
ユーザーエージェントは、次の条件に一致するコマンドを公開してもよい:
ユーザーエージェントは、ユーザーにこれらのキーを通知するための方法として、アクセスキーを持つコマンドのために特にこれを行うことが推奨される。
たとえば、そのようなコマンドは、ユーザーエージェントのメニューバーにリストされるかもしれない。
a
element to define a commandAn a
element with an href
attribute defines a command.
The Label of the command is the element's descendant text content.
The Access Key of the command is the element's assigned access key, if any.
The
of the command is true (hidden) if the element has a attribute, and false otherwise.The Disabled State facet of the command is true if the element or one of its ancestors is inert, and false otherwise.
The Action of the command is to fire a click
event at the element.
button
element to define a commandA button
element always defines a command.
The Label, Access Key, , and Action facets of the command are determined as for a
elements (see the previous section).
The Disabled State of the command is true if the element or one of its ancestors is inert, or if the element's disabled state is set, and false otherwise.
input
element to define a commandAn input
element whose type
attribute is in one of the Submit Button, Reset Button, Image Button, Button, Radio Button, or Checkbox states defines a command.
The Label of the command is determined as follows:
If the type
attribute is in one of the Submit Button, Reset Button, Image Button, or Button states, then the Label is the string given by the value
attribute, if any, and a UA-dependent, locale-dependent value that the UA uses to label the button itself if the attribute is absent.
Otherwise, if the element is a labeled control, then the Label is the descendant text content of the first label
element in tree order whose labeled control is the element in question. (In JavaScript terms, this is given by element.labels[0].textContent
.)
Otherwise, if the value
attribute is present, then the Label is the value of that attribute.
Otherwise, the Label is the empty string.
Even though the value
attribute on input
elements in the Image Button state is non-conformant, the attribute can still contribute to the Label determination, if it is present and the Image Button's alt
attribute is missing.
The Access Key of the command is the element's assigned access key, if any.
The
of the command is true (hidden) if the element has a attribute, and false otherwise.The Disabled State of the command is true if the element or one of its ancestors is inert, or if the element's disabled state is set, and false otherwise.
The Action of the command is to fire a click
event at the element.
option
element to define a commandAn option
element with an ancestor select
element and either no value
attribute or a value
attribute that is not the empty string defines a command.
The Label of the command is the value of the option
element's label
attribute, if there is one, or else the option
element's descendant text content, with ASCII whitespace stripped and collapsed.
The Access Key of the command is the element's assigned access key, if any.
The
of the command is true (hidden) if the element has a attribute, and false otherwise.The Disabled State of the command is true if the element is disabled, or if its nearest ancestor select
element is disabled, or if it or one of its ancestors is inert, and false otherwise.
If the option
's nearest ancestor select
element has a multiple
attribute, the Action of the command is to toggle the option
element. Otherwise, the Action is to pick the option
element.
accesskey
attribute on a legend
element to define a commandA legend
element defines a command if all of the following are true:
It has an assigned access key.
It is a child of a fieldset
element.
Its parent has a descendant that defines a command that is neither a label
element nor a legend
element. This element, if it exists, is the legend
element's accesskey
delegatee.
The Label of the command is the element's descendant text content.
The Access Key of the command is the element's assigned access key.
The Disabled State, and Action facets of the command are the same as the respective facets of the legend
element's accesskey
delegatee.
In this example, the legend
element specifies an accesskey
, which, when activated, will delegate to the input
element inside the legend
element.
< fieldset >
< legend accesskey = p >
< label > I want < input name = pizza type = number step = 1 value = 1 min = 0 >
pizza(s) with these toppings</ label >
</ legend >
< label >< input name = pizza-cheese type = checkbox checked > Cheese</ label >
< label >< input name = pizza-ham type = checkbox checked > Ham</ label >
< label >< input name = pizza-pineapple type = checkbox > Pineapple</ label >
</ fieldset >
accesskey
attribute to define a command on other elementsAn element that has an assigned access key defines a command.
If one of the earlier sections that define elements that define commands define that this element defines a command, then that section applies to this element, and this section does not. Otherwise, this section applies to that element.
The Label of the command depends on the element. If the element is a labeled control, the descendant text content of the first label
element in tree order whose labeled control is the element in question is the Label (in JavaScript terms, this is given by element.labels[0].textContent
). Otherwise, the Label is the element's descendant text content.
The Access Key of the command is the element's assigned access key.
The
of the command is true (hidden) if the element has a attribute, and false otherwise.The Disabled State of the command is true if the element or one of its ancestors is inert, and false otherwise.
The Action of the command is to run the following steps:
click
event at the element.dialog
要素Support in all current engines.
Support in all current engines.
open
— ダイアログボックスが見えるかどうか[Exposed =Window ]
interface HTMLDialogElement : HTMLElement {
[HTMLConstructor ] constructor ();
[CEReactions ] attribute boolean open ;
attribute DOMString returnValue ;
[CEReactions ] undefined show ();
[CEReactions ] undefined showModal ();
[CEReactions ] undefined close (optional DOMString returnValue );
};
dialog
要素は、小さいウィンドウ("ダイアログボックス")の形式で、ユーザーはこのウィンドウを操作してタスクを実行したり、情報を収集したりする、アプリケーションの一時的な部分を表す。ユーザーが終了すると、ダイアログはアプリケーションによって自動的に閉じる、またはユーザーによって手動で閉じることができる。
すべてのタイプのアプリケーションでおなじみのパターンである、特にモーダルダイアログの場合、著者は、ウェブアプリケーション内のダイアログが、非ウェブアプリケーションのユーザーにも馴染みのある方法で動作するように保証すべきである。
すべてのHTML要素と同様に、別のタイプのコントロールを表現しようとするときにdialog
要素を使用することは適合しない。たとえば、コンテキストメニュー、ツールチップ、ポップアップリストボックスは、ダイアログボックスではないため、これらのパターンを実装するためにdialog
要素を乱用することは正しくない。
ユーザー向けダイアログの動作で重要な部分は、初期のフォーカスの配置である。ダイアログフォーカスステップは、ダイアログが表示されたときに初期のフォーカスの適切な候補を選択しようするが、特定のダイアログに対するユーザーの期待に沿う正確な選択を慎重に検討する著者の代わりにはならないかもしれない。そのため、著者は、ダイアログが開いた後にユーザーがすぐに対話することが期待されるダイアログの子孫要素に対して、autofocus
属性を使用すべきである。そのような要素がない場合、著者はdialog
要素自体にautofocus
属性を使用すべきである。
次の例では、在庫管理ウェブアプリケーションで製品の詳細を編集するためにダイアログが使用される。
< dialog >
< label > Product Number < input type = "text" readonly ></ label >
< label > Product Name < input type = "text" autofocus ></ label >
</ dialog >
autofocus
属性が存在しない場合、Product Numberフィールドはダイアログフォーカスステップによってフォーカスされる。これは合理的な動作であるが、Product Numberフィールドは読み取り専用であり、ユーザー入力を想定していないため、Product Nameフィールドにフォーカスを当てる方が適切であると著者は判断した。そこで、著者はデフォルトを上書きするためにオートフォーカスを使用した。
たとえ著者がデフォルトでProduct Numberフィールドにフォーカスしたいとしても、input
要素にオートフォーカスを使用して明示的に指定するのが最良である。これは、コードの将来の読者に対して意図を明確にし、将来の更新に対してコードが堅牢であり続けることを保証する。(たとえば、別の開発者が閉じるボタンを追加し、ノードツリーのProduct Numberフィールドの前に配置した場合)。
ユーザー動作のもう1つの重要な側面は、ダイアログがスクロール可能かどうかということである。場合によっては、オーバーフロー(つまりスクロール可能性)は、例えば、ユーザーの高いテキストズーム設定によって引き起こされる場合、回避することができない。しかし一般に、スクロール可能なダイアログはユーザーには期待されない。大きなテキストノードをダイアログ要素に直接追加すると、ダイアログ要素自体がオーバーフローする可能性があるため、特に問題が多い。著者はそれらを避けるのが最善である。
次のサービス条件のダイアログでは、上記の提案を尊重する。
< dialog style = "height: 80vh;" >
< div style = "overflow: auto; height: 60vh;" autofocus >
< p > By placing an order via this Web site on the first day of the fourth month of the year
2010 Anno Domini, you agree to grant Us a non-transferable option to claim, for now and for
ever more, your immortal soul.</ p >
< p > Should We wish to exercise this option, you agree to surrender your immortal soul,
and any claim you may have on it, within 5 (five) working days of receiving written
notification from this site or one of its duly authorized minions.</ p >
<!-- ... etc., with many more <p> elements ... -->
</ div >
< form method = "dialog" >
< button type = "submit" value = "agree" > Agree</ button >
< button type = "submit" value = "disagree" > Disagree</ button >
</ form >
</ dialog >
ダイアログフォーカスステップは、デフォルトでスクロール可能なdiv
要素が選択されるが、直前の例と同様に、将来の変更に対してより明確で堅牢になるように、autofocus
をdiv
に配置した。
対照的に、利用規約を表すp
要素にそのようなラッパーdiv
要素がない場合、dialog
自身がスクロール可能になり、上記のアドバイスに違反する。さらに、autofocus
属性が存在しない場合、そのようなマークアップパターンは上記のアドバイスに違反し、ダイアログフォーカスステップのデフォルト動作を中断させ、フォーカスがAgree button
にジャンプする原因となる。これは、悪いユーザー体験となる。
open
属性は、真偽属性である。指定される場合、dialog
要素はアクティブであり、ユーザーが操作できることを示す。
open
属性が指定されないdialog
要素は、ユーザーに表示されるべきでない。この要件は、スタイルレイヤーを通して間接的に実装されてもよい。たとえば、推奨されるデフォルトのレンダリングをサポートするユーザーエージェントは、Renderingセクションで説明されるCSSルールを使用してこの要件を実装する。
open
属性を削除すると、通常ダイアログが非表示になる。しかし、そのようにすると、いくつかの奇妙な追加の結果となる:
close
イベントは発火しない。
close()
メソッドとユーザーエージェントが提供する取り消しインターフェイスは、もはやダイアログを閉じることができなくなる。
showModal()
メソッドを使用してダイアログが表示された場合、Document
はブロックされる。
これらの理由から、open
属性を手動で削除しない方が一般的には良い方法である。代わりに、ダイアログを閉じるためにclose()
メソッドを使用する、または非表示にするために 属性を使用する。
tabindex
属性は、dialog
要素で指定されてはならない。
dialog.show()
Support in all current engines.
dialog
要素を表示する。
dialog.showModal()
Support in all current engines.
dialog
要素を表示し、一番上のモーダルダイアログにする。
この方法は、autofocus
属性を履行する。
dialog.close([ result ])
Support in all current engines.
dialog
要素を閉じる。
引数が与えられた場合、戻り値を提供する。
dialog.returnValue [ = result ]
Support in all current engines.
dialog
の戻り値を返す。
戻り値を更新する設定が可能である。
The show()
method steps are:
If this has an open
attribute and the is modal flag of this is false, then return.
If this has an open
attribute, then throw an "InvalidStateError
" DOMException
.
If this is in the popover showing state, then throw an "InvalidStateError
" DOMException
.
Add an open
attribute to this, whose value is the empty string.
Set this's previously focused element to the focused element.
Run hide all popovers given this's node document.
Run the dialog focusing steps given this.
The showModal()
method steps are:
If this has an open
attribute and the is modal flag of this is true, then return.
If this has an open
attribute, then throw an "InvalidStateError
" DOMException
.
If this is not connected, then throw an "InvalidStateError
" DOMException
.
If this is in the popover showing state, then throw an "InvalidStateError
" DOMException
.
Add an open
attribute to this, whose value is the empty string.
Let this's node document be blocked by the modal dialog this.
This will cause the focused area of the document to become inert (unless that currently focused area is a shadow-including descendant of subject). In such cases, the focused area of the document will soon be reset to the viewport. In a couple steps we will attempt to find a better candidate to focus.
If this's node document's top layer does not already contain this, then add this to this's node document's top layer.
Set this's previously focused element to the focused element.
Run hide all popovers given this's node document.
Run the dialog focusing steps given this.
The dialog focusing steps, given a dialog
element subject, are as follows:
Let control be null.
If subject has the autofocus
attribute, then set control to subject.
If control is null, then set control to the focus delegate of subject.
If control is null, then set control to subject.
Run the focusing steps for control.
If control is not focusable, this will do nothing. This would only happen if subject had no focus delegate, and the user agent decided that dialog
elements were not generally focusable. In that case, any earlier modifications to the focused area of the document will apply.
Let topDocument be control's node navigable's top-level traversable's active document.
If control's node document's origin is not the same as the origin of topDocument, then return.
Empty topDocument's autofocus candidates.
Set topDocument's autofocus processed flag to true.
If at any time a dialog
element is removed from a Document
, then if that dialog
is in that Document
's top layer, it must be removed from it. Also, set the dialog
element's is modal flag to false.
The close(returnValue)
method steps are:
If returnValue is not given, then set it to null.
Close the dialog this with returnValue.
When a dialog
element subject is to be closed, with null or a string result, run these steps:
If subject does not have an open
attribute, then return.
Remove subject's open
attribute.
Set the is modal flag of subject to false.
If result is not null, then set the returnValue
attribute to result.
If subject's previously focused element is not null, then:
Let element be subject's previously focused element.
Set subject's previously focused element to null.
If subject's node document's focused area of the document's DOM anchor is a shadow-including inclusive descendant of element, or subject's is modal is true, then run the focusing steps for element; the viewport should not be scrolled by doing this step.
Queue an element task on the user interaction task source given the subject element to fire an event named close
at subject.
The returnValue
IDL attribute, on getting, must return the last value to which it was set. On setting, it must be set to the new value. When the element is created, it must be set to the empty string.
次の制約により、表示する/隠す(show/hide)や開く/閉じる(open/close)などの対義語として一般的に考えられている動詞のペアとは対照的に、dialog
要素の動詞として表示する/閉じる(show/close)を使用する:
ダイアログを非表示にすることは、ダイアログを閉じることとは異なる。ダイアログを閉じると、戻り値が返され、イベントが発火し、他のダイアログのページのブロックが解除される、などする。ダイアログを非表示にすることは純粋に視覚的なプロパティであり、open
属性を削除することですでに実行できることである。(open
属性を削除すること、およびそのようにダイアログを非表示にすることは一般的に望ましくないことについては、上記の注も参照。)
ダイアログを表示することは、ダイアログを開くこととは異なる。ダイアログを開くことは、そのダイアログを作成して、表示することである(window.open()
が新しいウィンドウを作成して表示する方法と同様である)。ダイアログの表示は、すでにDOMにあるdialog
要素を取得し、それをインタラクティブにしてユーザーに可視にするプロセスである。
上記にもかかわらずdialog.open()
メソッドがあるとすれば、dialog.open
プロパティと競合するだろう。
さらに、dialog
要素のもとのデザインと同時代の他の多くのUIフレームワークの調査により、表示する/閉じる(show/close)の動詞のペアがかなり一般的であることが明らかになった。
要約すると、特定の動詞の意味、およびそれらの動詞が技術的なコンテキストでどのように使用されるかは、ダイアログの表示と閉じるなどのペアの動作が必ずしも対義語として表現できるとは限らないことがわかる。
Canceling dialogs: When Document
is blocked by a modal dialog dialog, user agents may provide a user interface that, upon activation, queues an element task on the user interaction task source given the dialog element to run these steps:
Let close be the result of firing an event named cancel
at dialog, with the cancelable
attribute initialized to true.
If close is true, then close the dialog dialog with null.
An example of such a UI mechanism would be the user pressing the "Escape" key.
Each dialog
element has an is modal flag. When a dialog
element is created, this flag must be set to false.
Each HTML element has a previously focused element which is null or an element, and it is initially null. When showModal()
and show()
are called, this element is set to the currently focused element before running the dialog focusing steps. Elements with the popover
attribute set this element to the currently focused element during the show popover algorithm.
Support in all current engines.
open
IDL属性は、open
コンテンツ属性を反映しなければならない。
このダイアログボックスは、いくつかの小さなプリントを持つ。strong
要素は、より重要な部分にユーザーの注意を引くために使用される。
< dialog >
< h1 > Add to Wallet</ h1 >
< p >< strong >< label for = amt > How many gold coins do you want to add to your wallet?</ label ></ strong ></ p >
< p >< input id = amt name = amt type = number min = 0 step = 0.01 value = 100 ></ p >
< p >< small > You add coins at your own risk.</ small ></ p >
< p >< label >< input name = round type = checkbox > Only add perfectly round coins</ label ></ p >
< p >< input type = button onclick = "submit()" value = "Add Coins" ></ p >
</ dialog >