1. 4.11 インタラクティブ要素
      1. 4.11.1 details要素
      2. 4.11.2 summary要素
      3. 4.11.3 コマンド
        1. 4.11.3.1 ファセット
        2. 4.11.3.2 Using the a element to define a command
        3. 4.11.3.3 Using the button element to define a command
        4. 4.11.3.4 Using the input element to define a command
        5. 4.11.3.5 Using the option element to define a command
        6. 4.11.3.6 Using the accesskey attribute on a legend element to define a command
        7. 4.11.3.7 Using the accesskey attribute to define a command on other elements
      4. 4.11.4 dialog要素

4.11 インタラクティブ要素

4.11.1 details要素

Support: detailsChrome for Android 61+Chrome 12+iOS Safari 6.0+UC Browser for Android 11.4+Firefox 49+Samsung Internet 4+IE NoneSafari 6+Edge NoneAndroid Browser 4+Opera 15+

Source: caniuse.com

カテゴリー
フローコンテンツ
セクショニングルート
インタラクティブコンテンツ
パルパブルコンテンツ
この要素を使用できるコンテキスト
フローコンテンツが期待される場所。
コンテンツモデル
1つのsummary要素に続くフローコンテンツ
text/htmlにおけるタグ省略
どちらのタグも省略不可。
コンテンツ属性
グローバル属性
open — detailsが可視かどうか
DOMインターフェイス
[Exposed=Window,
 HTMLConstructor]
interface HTMLDetailsElement : HTMLElement {
  [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 a task that runs the following steps, which are known as the details notification task steps, for this details element:

  1. If another task has been queued to run the details notification task steps for this details element, then abort these steps.

    When the open attribute is toggled several times in succession, these steps essentially get coalesced so that only one event is fired.

  2. Fire an event named toggle at the details element.

このタスクのためのタスクソースは、DOM操作タスクソースである。

open IDL属性は、openコンテンツ属性を反映しなければならない。

次の例は、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で要素に使用できる。これは、スタイルシートが要素を開いたり閉じたりする際に、要約の色をアニメーション化するために使用される:

<style>
 details > summary { transition: color 1s; color: black; }
 details[open] > summary { color: red; }
</style>
<details>
 <summary>Automated Status: Operational</summary>
 <p>Velocity: 12m/s</p>
 <p>Direction: North</p>
</details>

4.11.2 summary要素

カテゴリー
なし。
この要素を使用できるコンテキスト
details要素の最初の子として。
コンテンツモデル
いずれか:フレージングコンテンツ
または:ヘディングコンテンツの1つの要素。
text/htmlにおけるタグ省略
どちらのタグも省略不可。
コンテンツ属性
グローバル属性
DOMインターフェイス
HTMLElementを使用する。

summary要素は、もしあれば、summary要素の親details要素に属する残りの内容のキャプションまたは凡例を表す

The activation behavior of summary elements is to run the following steps:

  1. If this summary element has no parent node, then abort these steps.

  2. Let parent be this summary element's parent node.

  3. If parent is not a details element, then abort these steps.

  4. If parent's first summary element child is not this summary element, then abort these steps.

  5. 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.

4.11.3 コマンド

4.11.3.1 ファセット

コマンドは、メニュー項目、ボタン、リンクの背後に抽象化したものである。一度コマンドが定義されると、インターフェイスの他の部分は、Disabled状態のようなファセットを共有するために単一の機能へ多くのアクセスポイントを許可し、同じコマンドを参照できる。

コマンドは、次のファセットを持つように定義される:

ラベル
ユーザーから見たコマンドの名前。
アクセスキー
コマンドを切り替えるユーザーエージェントによって選択されたキーの組み合わせ。コマンドはアクセスキーを持たないかもしれない。
Hidden状態
コマンドが非表示にされたかどうか(基本的に、メニューに表示するかどうか)。
Disabled状態
コマンドが関連するおよび切り替え可能かどうか。
アクション
コマンドを切り替える実際の効果がもつもの。これは、スクリプト化されたイベントハンドラー、どのようにナビゲートするためのURL、またはフォーム送信であるかもしれない。

ユーザーエージェントは、次の条件に一致するコマンドを公開してもよい:

ユーザーエージェントは、ユーザーにこれらのキーを通知するための方法として、アクセスキーを持つコマンドのために特にこれを行うことが推奨される。

たとえば、そのようなコマンドは、ユーザーエージェントのメニューバーにリストされるかもしれない。

4.11.3.2 Using the a element to define a command

An a element with an href attribute defines a command.

The Label of the command is the string given by the element's textContent IDL attribute.

The AccessKey of the command is the element's assigned access key, if any.

The Hidden State of the command is true (hidden) if the element has a hidden 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.

4.11.3.3 Using the button element to define a command

A button element always defines a command.

The Label, Access Key, Hidden State, 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.

4.11.3.4 Using the input element to define a command

An 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:

The AccessKey of the command is the element's assigned access key, if any.

The Hidden State of the command is true (hidden) if the element has a hidden 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.

4.11.3.5 Using the option element to define a command

An 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 value of option element's textContent IDL attribute, with ASCII whitespace stripped and collapsed.

The AccessKey of the command is the element's assigned access key, if any.

The Hidden State of the command is true (hidden) if the element has a hidden 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.

4.11.3.6 Using the accesskey attribute on a legend element to define a command

A legend element that has an assigned access key and is a child of a fieldset element that has a descendant that is not a descendant of the legend element and is neither a label element nor a legend element but that defines a command, itself defines a command.

The Label of the command is the string given by the element's textContent IDL attribute.

The AccessKey of the command is the element's assigned access key.

The Hidden State, Disabled State, and Action facets of the command are the same as the respective facets of the first element in tree order that is a descendant of the parent of the legend element that defines a command but is not a descendant of the legend element and is neither a label nor a legend element.

4.11.3.7 Using the accesskey attribute to define a command on other elements

An 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 textContent of the first label element in tree order whose labeled control is the element in question is the Label (in DOM terms, this is the string given by element.labels[0].textContent). Otherwise, the Label is the textContent of the element itself.

The AccessKey of the command is the element's assigned access key.

The Hidden State of the command is true (hidden) if the element has a hidden 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:

  1. Run the focusing steps for the element.
  2. Fire a click event at the element.

4.11.4 dialog要素

Support: dialogChrome for Android 61+Chrome 37+iOS Safari NoneUC Browser for Android 11.4+Firefox NoneSamsung Internet 4+IE NoneOpera Mini NoneSafari NoneEdge NoneAndroid Browser 56+Opera 24+

Source: caniuse.com

カテゴリー
フローコンテンツ
セクショニングルート
この要素を使用できるコンテキスト
フローコンテンツが期待される場所。
コンテンツモデル
フローコンテンツ
text/htmlにおけるタグ省略
どちらのタグも省略不可。
コンテンツ属性
グローバル属性
open — ダイアログボックスが見えるかどうか
DOMインターフェイス
[Exposed=Window,
 HTMLConstructor]
interface HTMLDialogElement : HTMLElement {
  [CEReactions] attribute boolean open;
  attribute DOMString returnValue;
  [CEReactions] void show();
  [CEReactions] void showModal();
  [CEReactions] void close(optional DOMString returnValue);
};

dialog要素は、たとえばダイアログボックス、インスペクタ、またはウィンドウなどのタスクを実行するために、ユーザーが操作するアプリケーションの一部を表す。

open属性は、真偽属性である。指定される場合、dialog要素はアクティブであり、ユーザーが操作できることを示す。

A dialog element without an open attribute specified should not be shown to the user. この要件は、スタイルレイヤーを通して間接的に実装されてもよい。For example, user agents that support the suggested default rendering implement this requirement using the CSS rules described in the rendering section.

open属性を削除すると、通常ダイアログが非表示になる。しかし、そのようにすると、いくつかの奇妙な追加の結果となる:

これらの理由から、open属性を手動で削除しない方が一般的には良い方法である。代わりに、ダイアログを閉じるためにclose()メソッドを使用する、または非表示にするためにhidden属性を使用する。

tabindex属性は、dialog要素で指定されてはならない。

dialog . show()

dialog要素を表示する。

dialog . showModal()

dialog要素を表示し、一番上のモーダルダイアログにする。

この方法は、autofocus属性を履行する。

dialog . close( [ result ] )

dialog要素を閉じる。

引数が与えられた場合、戻り値を提供する。

dialog . returnValue [ = result ]

dialogの戻り値を返す。

戻り値を更新する設定が可能である。

When the show() method is invoked, the user agent must run the following steps:

  1. If the element already has an open attribute, then abort these steps.

  2. Add an open attribute to the dialog element, whose value is the empty string.

  3. Set the dialog to the normal alignment mode.

  4. Run the dialog focusing steps for the dialog element.

When the showModal() method is invoked, the user agent must run the following steps:

  1. Let subject be the dialog element on which the method was invoked.

  2. If subject already has an open attribute, then throw an "InvalidStateError" DOMException and abort these steps.

  3. If subject is not connected, then throw an "InvalidStateError" DOMException and abort these steps.

  4. Add an open attribute to subject, whose value is the empty string.

  5. Set the dialog to the centered alignment mode.

  6. Let subject's node document be blocked by the modal dialog subject.

  7. If subject's node document's top layer does not already contain subject, then add subject to subject's node document's top layer.

  8. Run the dialog focusing steps for subject.

The dialog focusing steps for a dialog element subject are as follows:

  1. If for some reason subject is not a control group owner object at this point, or if it is inert, abort these steps.

  2. Let control be the first non-inert focusable area in subject's control group whose DOM anchor has an autofocus attribute specified.

    If there isn't one, then let control be the first non-inert focusable area in subject's control group.

    If there isn't one of those either, then let control be subject.

  3. Run the focusing steps for control.

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.

When the close() method is invoked, the user agent must close the dialog that the method was invoked on. If the method was invoked with an argument, that argument must be used as the return value; otherwise, there is no return value.

When a dialog element subject is to be closed, optionally with a return value result, the user agent must run the following steps:

  1. If subject does not have an open attribute, then abort these steps.

  2. Remove subject's open attribute.

  3. If the argument result was provided, then set the returnValue attribute to the value of result.

  4. If subject is in its Document's top layer, then remove it.

  5. Queue a task 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.


Canceling dialogs: When Document is blocked by a modal dialog dialog, user agents may provide a user interface that, upon activation, queues a task to run these steps:

  1. Let close be the result of firing an event named cancel at dialog, with the cancelable attribute initialized to true.

  2. If close is true and dialog has an open attribute, then close the dialog with no return value.

An example of such a UI mechanism would be the user pressing the "Escape" key.


A dialog element is in one of two modes: normal alignment or centered alignment. When a dialog element is created, it must be placed in the normal alignment mode. In this mode, normal CSS requirements apply to the element. The centered alignment mode is only used for dialog elements that are in the top layer. [FULLSCREEN] [CSS]

When an element subject is placed in centered alignment mode, and when it is in that mode and has new rendering boxes created, the user agent must set up the element such that its static position of the edge that corresponds to subject's parent's block-start edge, for the purposes of calculating the used value of the appropriate box offset property ('top', 'right', 'bottom', or 'left'), is the value that would place the element's margin edge on the side that corresponds to subject's parent's block-start side as far from the same-side edge of the viewport as the element's opposing side margin edge from that same-side edge of the viewport, if the element's dimension ('width' or 'height') in subject's parent's block flow direction is less than the same-axis dimension of the viewport, and otherwise is the value that would place the element's margin edge on the side that corresponds to subject's parent's block-start side at the same-side edge of the viewport.

If there is a dialog element with centered alignment and that is being rendered when its browsing context changes viewport dimensions (as measured in CSS pixels), or when this dialog element's parent changes block flow direction, then the user agent must recreate the element's boxes, recalculating its edge that corresponds to this dialog element's parent's block-start edge as in the previous paragraph.

This static position of a dialog element's edge with centered alignment must remain the element's static position of that edge until its boxes are recreated. (The element's static position is only used in calculating the used value of the appropriate box offset property ('top', 'right', 'bottom', or 'left') in certain situations; it's not used, for instance, to position the element if its 'position' property is set to 'static'.)

User agents in visual interactive media should allow the user to pan the viewport to access all parts of a dialog element's border box, even if the element is larger than the viewport and the viewport would otherwise not have a scroll mechanism (e.g. because the viewport's 'overflow' property is set to 'hidden').


open IDL属性は、openコンテンツ属性を反映しなければならない。

このダイアログボックスは、いくつかの小さなプリントを持つ。main要素は、より重要な部分にユーザーの注意を引くために使用される。

<dialog>
 <h1>Add to Wallet</h1>
 <main>
  <p>How many gold coins do you want to add to your wallet?</p>
  <p><input name=amt type=number min=0 step=0.01 value=100></p>
 </main>
 <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><input type=button onclick="submit()" value="Add Coins"></p>
</dialog>