1. 6 ユーザーとの対話処理
    1. 6.1 hidden属性
    2. 6.2 ページの可視
      1. 6.2.1 VisibilityStateEntryインターフェイス
    3. 6.3 不活性サブツリー
      1. 6.3.1 モーダルダイアログと不活性サブツリー
      2. 6.3.2 inert属性
    4. 6.4 ユーザーのアクティブ化の追跡
      1. 6.4.1 UserActivationインターフェイス
    5. 6.5 要素のアクティブ化動作
      1. 6.5.1 The ToggleEvent interface
    6. 6.6 フォーカス
      1. 6.6.1 導入
      2. 6.6.2 データモデル
      3. 6.6.3 tabindex属性
      4. 6.6.4 フォーカス管理API
      5. 6.6.5 autofocus属性
    7. 6.7 キーボードショートカットの割り当て
      1. 6.7.1 導入
      2. 6.7.2 accesskey属性
    8. 6.8 編集
      1. 6.8.1 編集可能な文書領域を作成する:contenteditableコンテンツ属性
      2. 6.8.2 文書全体を編集可能にする:designModeのゲッターおよびセッター
      3. 6.8.3 ページ内編集者のためのベストプラクティス
      4. 6.8.4 スペルと文法チェック
      5. 6.8.5 Writing suggestions
      6. 6.8.6 自動大文字化
      7. 6.8.7 入力モダリティ:inputmode属性
      8. 6.8.8 入力モダリティ:enterkeyhint属性
    9. 6.9 ページ内検索
      1. 6.9.1 導入
      2. 6.9.2 detailshidden=until-foundとの相互作用
      3. 6.9.3 選択との相互作用
    10. 6.10 Close requests and close watchers
      1. 6.10.1 Close requests
      2. 6.10.2 The CloseWatcher interface

6 ユーザーとの対話処理

6.1 hidden属性

Global_attributes/hidden

Support in one engine only.

FirefoxNoSafariNoChrome102+
OperaNoEdge102+
Edge (Legacy)?Internet ExplorerNo
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android?

Global_attributes/hidden

Support in all current engines.

Firefox4+Safari5.1+Chrome10+
Opera?Edge79+
Edge (Legacy)12+Internet Explorer11
Firefox Android?Safari iOS?Chrome Android?WebView Android4+Samsung Internet?Opera Android?

すべてのHTML要素hiddenコンテンツ属性設定を持ってもよい。The hidden attribute is an enumerated attribute with the following keywords and states:

キーワード状態概要
hidden非表示Will not be rendered.
(空文字列)
until-foundhidden until foundWill not be rendered, but content inside will be accessible to find-in-page and fragment navigation.

The attribute's missing value default is the not hidden state, and its invalid value default is the hidden state.

When an element has the hidden attribute in the hidden state, it indicates that the element is not yet, or is no longer, directly relevant to the page's current state, or that it is being used to declare content to be reused by other parts of the page as opposed to being directly accessed by the user. User agents should not render elements that are in the hidden state. この要件は、スタイルレイヤーを通して間接的に実装されてもよい。たとえば、ウェブブラウザーは、レンダリングセクションで提案されているルールを使用してこれらの要件を実装することができる。

When an element has the hidden attribute in the hidden until found state, it indicates that the element is hidden like the hidden state but the content inside the element will be accessible to find-in-page and fragment navigation. これらの機能が要素のサブツリーにあるターゲットにスクロールしようとするとき、ユーザーエージェントは、スクロールする前にコンテンツを表示するためにhidden属性を削除する。 hidden属性を削除することに加えて、beforematchという名前のイベントも、hidden属性が削除される前に要素で発火する。

Web browsers will use 'content-visibility: hidden' instead of 'display: none' when the hidden attribute is in the hidden until found state, as specified in the Rendering section.

この属性は通常CSSを使用して実装されているため、CSSを使用して上書きすることもできる。たとえば、'display: block'をすべての要素に適用する規則は、hidden状態の影響を相殺するだろう。したがって著者は、期待通りに属性がスタイル付けされていることを確認し、そのスタイルシートを書くときに注意する必要がある。In addition, legacy user agents which don't support the hidden until found state will have 'display: none' instead of 'content-visibility: hidden', so authors are encouraged to make sure that their style sheets don't change the 'display' or 'content-visibility' properties of hidden until found elements.

Since elements with the hidden attribute in the hidden until found state use 'content-visibility: hidden' instead of 'display: none', there are two caveats of the hidden until found state that make it different from the hidden state:

  1. ページ内検索で表示するには、要素がレイアウトの包含の影響を受ける必要がある。 This means that if the element in the hidden until found state has a 'display' value of 'none', 'contents', or 'inline', then the element will not be revealed by find-in-page.

  2. The element will still have a generated box when in the hidden until found state, which means that borders, margin, and padding will still be rendered around the element.

以下の骨格の例において、属性は、ユーザーがログインするまでウェブゲームのメイン画面を非表示にするために使用される:

  <h1>The Example Game</h1>
  <section id="login">
   <h2>Login</h2>
   <form>
    ...
    <!-- calls login() once the user's credentials have been checked -->
   </form>
   <script>
    function login() {
      // switch screens
      document.getElementById('login').hidden = true;
      document.getElementById('game').hidden = false;
    }
   </script>
  </section>
  <section id="game" hidden>
   ...
  </section>

hidden属性は、別のプレゼンテーションに合法的に示すことができたコンテンツを隠すために使用されてはならない。たとえば、タブ付きインターフェイスは単にオーバーフロープレゼンテーションの一種であるため、タブ付きダイアログでパネルを隠すためにhiddenを使用することは誤りである。―それはスクロールバーをもつ1つの大きなページ内のすべてのフォームコントロールを示すのと同様である。ちょうど1つのプレゼンテーションからコンテンツを非表示にするためにこの属性を使用することも同様に誤りである。―何かがhiddenとマークされる場合、それは、たとえばスクリーンリーダーなどを含む、すべてのプレゼンテーションから隠されている。

自身がhiddenでない要素は、hiddenである要素へハイパーリンクされてはならない。自身がhiddenでないlabelおよびoutput要素のfor属性も同様に、hiddenである要素を参照してはならない。どちらの場合も、このような参照はユーザーの混乱を引き起こすだろう。

しかし、要素およびスクリプトは、他のコンテキストでhiddenである要素を参照してもよい。

たとえば、hidden属性でマークされたセクションにリンクするhref属性を使用するのは誤りだろう。コンテンツが適切または関連しない場合、それにリンクする理由はない。

しかし、自身がhiddenである説明を参照するために、ARIA aria-describedby属性を使用することは構わない。説明を非表示にすることはそれらが単独で有用でないことを意味する一方で、それらは、それらが説明する要素から参照される特定のコンテキストにおいて有用である方法で記述することもできる。

同様に、hidden属性を持つcanvas要素は、オフスクリーンバッファーとしてスクリプト化されたグラフィックスエンジンによって使用されるかもしれず、フォームコントロールは、form属性を使用する隠しform要素を参照するかもしれない。

hidden属性によって非表示にされたセクション内の要素は依然としてアクティブである。たとえば、そのようなセクションでのスクリプトやフォームコントロールは、依然として実行および送信する。それらのプレゼンテーションのみがユーザーに変更される。

6.2 ページの可視

作成時の初期値を含む、トラバース可能なナビゲート可能システム可視状態は、ユーザー エージェントによって決定される。たとえば、ブラウザーウィンドウが最小化されているか、ブラウザータブが現在バックグラウンドにあるか、またはタスクスイッチャーなどのシステム要素がページを覆い隠しているかどうかを表す。

When a user-agent determines that the system visibility state for traversable navigable traversable has changed to newState, it must run the following steps:

  1. Let navigables be the inclusive descendant navigables of traversable's active document.

  2. For each navigable of navigables in what order?:

    1. Let document be navigable's active document.

    2. Queue a global task on the user interaction task source given document's relevant global object to update the visibility state of document with newState.

Document可視状態を持ち、これは"hidden"または"visible"のいずれかで、最初は"hidden"に設定される。

Document/visibilityState

Support in all current engines.

Firefox18+Safari7+Chrome33+
Opera20+Edge79+
Edge (Legacy)12+Internet Explorer10+
Firefox Android?Safari iOS?Chrome Android?WebView Android4.4.3+Samsung Internet?Opera Android20+

visibilityStateゲッターの手順は、この可視状態を返すものである。

Document/hidden

Support in all current engines.

Firefox18+Safari7+Chrome33+
Opera12.1+Edge79+
Edge (Legacy)12+Internet Explorer10+
Firefox Android?Safari iOS?Chrome Android?WebView Android4.4.3+Samsung Internet?Opera Android12.1+

hiddenのゲッター手順は、この可視状態が"hidden"の場合はtrueを返し、それ以外の場合はfalseを返すものである。

To update the visibility state of Document document to visibilityState:

  1. If document's visibility state equals visibilityState, then return.

  2. Set document's visibility state to visibilityState.

  3. Queue a new VisibilityStateEntry whose visibility state is visibilityState and whose timestamp is the current high resolution time given document's relevant global object.

  4. Run the screen orientation change steps with document. [SCREENORIENTATION]

  5. Run the view transition page visibility change steps with document.

  6. Run any page visibility change steps which may be defined in other specifications, with visibility state and document.

    It would be better if specification authors sent a pull request to add calls from here into their specifications directly, instead of using the page visibility change steps hook, to ensure well-defined cross-specification call order. As of the time of this writing the following specifications are known to have page visibility change steps, which will be run in an unspecified order: Device Posture API and Web NFC. [DEVICEPOSTURE] [WEBNFC]

  7. Fire an event named visibilitychange at document, with its bubbles attribute initialized to true.

6.2.1 VisibilityStateEntryインターフェイス

VisibilityStateEntry

Support in one engine only.

FirefoxNoSafariNoChrome115+
Opera?Edge115+
Edge (Legacy)?Internet ExplorerNo
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android?

VisibilityStateEntryインターフェイスは、文書がアクティブになった瞬間から、文書の可視性の変更を公開する。

たとえば、これは、ページ内のJavaScriptコードが、可視性の変化とペイントのタイミングの相関関係を調べることを可能にする。
function wasHiddenBeforeFirstContentfulPaint() {
    const fcpEntry = performance.getEntriesByName("first-contentful-paint")[0];
    const visibilityStateEntries = performance.getEntriesByType("visibility-state");
    return visibilityStateEntries.some(e =>
                                            e.startTime < fcpEntry.startTime &&
                                            e.name === "hidden");
}

ページを非表示にすると、レンダリングおよびその他のユーザエージェント操作のスロットリングが発生する可能性があるため、そのようなスロットリングが発生したことを示すものとして、可視の変更を使用するのが一般的である。ただし、長時間の非アクティブ状態など、他の要因によっても、さまざまなブラウザーでスロットリングが発生する可能性がある。

VisibilityStateEntryは、関連付けられたDOMHighResTimeStampタイムスタンプを持つ。

VisibilityStateEntryは、関連付けられた"visible"または "hidden"可視状態を持つ。

nameゲッターステップは、this可視状態を返す。

entryTypeゲッターステップは、"visibility-state"を返す。

startTimeゲッターステップは、thisタイムスタンプを返す。

durationゲッターステップは0を返す。

6.3 不活性サブツリー

同じ名前の属性の説明については、inertも参照のこと。

ノード(特に要素およびテキストノード)は不活性である可能性がある。ノードが不活性である場合:

通例、不活性ノードにフォーカスを当てることはできず、ユーザーエージェントは非活性ノードをアクセシビリティAPIまたは支援技術に公開しない。コマンドである不活性ノードは、上記の方法ではユーザーには使用不能となる。

いずれにせよ、ユーザーエージェントは、ページ内検索およびテキスト選択の制限をユーザーが上書き可能にしてもよい。

デフォルトでは、ノードは不活性ではない。

subjectdocument最上位レイヤーの一番上のdialog要素である場合、Document documentモーダルダイアログボックスによってブロックされるsubjectである。documentがそのようにブロックされる一方で、document接続されているすべてのノードは、subject要素とそのフラットツリーの子孫を除き、不活性とマークされなければならない。

subjectは、inert属性を介してさらに不活性になることができるが、subject自体に指定されている場合に限る(つまり、subjectは祖先の不活性を回避する)。subjectフラットツリーの子孫は、同じように不活性になることがある。

dialog要素のshowModal()メソッドは、dialog要素をノード文書最上位レイヤー追加することによって、このメカニズムをトリガーさせる。

6.3.2 inert属性

Global_attributes/inert

Support in all current engines.

Firefox112+Safari15.5+Chrome102+
Opera?Edge102+
Edge (Legacy)?Internet ExplorerNo
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android?

inert属性は、その存在によって、(モーダルダイアログなど)他の方法では不活性化を免れない要素およびそのすべてのフラットツリーの子孫がユーザーエージェントによって不活性にされることを示す真偽属性である。

不活性サブツリーは、不活性状態ではないページの外観を理解または使用するために重要なコンテンツまたはコントロールを含むべきでない。不活性サブツリー内のコンテンツは、すべてのユーザーによって認識できる、またはインタラクティブではない。著者は、要素が表す内容が何らかの形で視覚的に隠されていない限り、要素を不活性と指定すべきでない。ほとんどの場合、著者は個々のフォームコントロールにinert属性を指定すべきでない。このような場合は、disabled属性の方がおそらく適切である。

次の例は、"loading"メッセージによって視覚的に隠されている、部分的に読み込まれたコンテンツを不活性としてマークする方法を示す。

<section aria-labelledby=s1>
  <h3 id=s1>Population by City</h3>
  <div class=container>
    <div class=loading><p>Loading...</p></div>
    <div inert>
      <form>
        <fieldset>
          <legend>Date range</legend>
          <div>
            <label for=start>Start</label>
            <input type=date id=start>
          </div>
          <div>
            <label for=end>End</label>
            <input type=date id=end>
          </div>
          <div>
            <button>Apply</button>
          </div>
        </fieldset>
      </form>
      <table>
        <caption>From 20-- to 20--</caption>
        <thead>
          <tr>
            <th>City</th>
            <th>State</th>
            <th>20-- Population</th>
            <th>20-- Population</th>
            <th>Percentage change</th>
          </tr>
        </thead>
        <tbody>
          <!-- ... -->
        </tbody>
      </table>
    </div>
  </div>
</section>
Screenshot of Population by City content with an overlaid loading message which visually obscures the form controls and data table which have not fully rendered, and thus are in the inert state.

"loading"のオーバーレイは、不活性のコンテンツを覆い隠し、不活性のコンテンツが現在アクセス可能でないことを視覚的に明らかにする。見出しおよび"loading"のテキストは、inert属性をもつ要素の子孫ではないことに注意する。これは、このテキストがすべてのユーザーをアクセス可能にするが、不活性のコンテンツは誰も操作できなくなる。

デフォルトでは、要素またはそのサブツリーが不活性であることを示す永続的な視覚的表示は存在しない。そのようなコンテンツに適切な視覚的なスタイルは、多くの場合、コンテキストに依存する。例えば、不活性な画面外のナビゲーションパネルは、その画面外の位置がコンテンツを視覚的にさえぎるので、デフォルトスタイルを必要としない。同様に、モーダルdialog要素のbackdropは、ウェブページの不活性なコンテンツを具体的にスタイル設定するのではなく、視覚的にさえぎる手段として機能する。

しかし、他の多くの状況では、ユーザーの混乱を避けるために、著者は文書のどの部分がアクティブで、どの部分が不活性であるかを明確にマークすることが強く勧める。特に、すべてのユーザーがページのすべての部分を一度に表示できるわけではないことを覚えておく価値がある。 たとえば、スクリーンリーダーのユーザー、小型のデバイスや拡大鏡を使用しているユーザー、特に小さなウィンドウを使用しているユーザーでさえ、ページのアクティブな部分を見ることができず、不活性なセクションが明らかに不活性でない場合はフラストレーションを感じる可能性がある。

HTMLElement/inert

Support in all current engines.

Firefox112+Safari15.5+Chrome102+
Opera?Edge102+
Edge (Legacy)?Internet ExplorerNo
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android?

inert IDL属性は、同じ名前のコンテンツ属性を反映しなければならない。

6.4 ユーザーのアクティブ化の追跡

ユーザーに迷惑となる可能性がある特定のAPI(ポップアップを開く、振動する電話など)の悪用を防ぐために、ユーザーエージェントは、ユーザーがウェブページをアクティブに操作している、または少なくとも1回はページを操作した場合にのみ、これらのAPIを許可する。この"アクティブな相互作用"の状態は、この節で定義されたメカニズムを通じて維持される。

ユーザーのアクティブ化に依存するAPIは、さまざまなレベルに分類される:

定着したアクティブ化ゲート型API

このAPIは、定着したアクティブ化状態がtrueである必要があるため、最初のユーザーによるアクティブ化までブロックされる。

一時的なアクティブ化ゲート型API

このAPIは、一時的なアクティブ化状態がtrueであることを必要とするが、それを消費しないため、一時的な状態が期限切れになるまで、ユーザーによるアクティブ化ごとに複数の呼び出しが許可される。

一時的なアクティブ化を消費するAPI

このAPIは、一時的なアクティブ化状態がtrueであることを必要とし、ユーザーによるアクティブ化ごとの複数の呼び出しを防ぐために、各呼び出しでユーザーによるアクティブ化を消費する

履歴アクションのアクティブ化を消費するAPI

このAPIは、履歴アクションのアクティブ化状態がtrueであることを要求し、ユーザーアクティブ化ごとに複数のコールが発生するのを防ぐために、各コールで履歴アクションのアクティブ化を消費する

6.4.1 UserActivationインターフェイス

UserActivation

FirefoxNoSafari16.4+Chrome72+
Opera?Edge79+
Edge (Legacy)?Internet ExplorerNo
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android?

Windowは、関連付けられたUserActivationを持ち、これはUserActivationオブジェクトである。Windowオブジェクトの作成時に、関連するUserActivationWindowオブジェクトの関連領域で作成された新しいUserActivationオブジェクトに設定しなければならない。

navigator.userActivation.hasBeenActive

Navigator/userActivation

FirefoxNoSafari16.4+Chrome72+
Opera?Edge79+
Edge (Legacy)?Internet ExplorerNo
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android?

UserActivation/hasBeenActive

FirefoxNoSafari16.4+Chrome72+
Opera?Edge79+
Edge (Legacy)?Internet ExplorerNo
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android?

ウィンドウがスティッキーアクティベーションを持つかどうかを返す。

navigator.userActivation.isActive

UserActivation/hasBeenActive

FirefoxNoSafari16.4+Chrome72+
Opera?Edge79+
Edge (Legacy)?Internet ExplorerNo
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android?

ウィンドウが一時的にアクティベーションを持つかどうかを返す。

6.5 要素のアクティブ化動作

HTMLの特定の要素は、ユーザーがアクティブにすることができることを意味する、アクティブ化動作を持つ。これは、常にclickイベントによって発生する。

element.click()

あたかも要素をクリックされたかのように動作する。

6.5.1 The ToggleEvent interface

event.oldState

ToggleEvent/oldState

Support in all current engines.

Firefox🔰 114+Safari17+Chrome114+
Opera?Edge114+
Edge (Legacy)?Internet ExplorerNo
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android?

クローズからオープンに遷移する場合は"closed"に設定し、オープンからクローズに遷移する場合は"open"に設定する。

event.newState

ToggleEvent/newState

Support in all current engines.

Firefox🔰 114+Safari17+Chrome114+
Opera?Edge114+
Edge (Legacy)?Internet ExplorerNo
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android?

クローズからオープンに遷移する場合は"open"に設定し、オープンからクローズに遷移する場合は"closed"に設定する。

The oldState and newState attributes must return the values they are initialized to.

A toggle task tracker is a struct which has:

task
A task which fires a ToggleEvent.
old state
oldState属性のタスクのイベントの値を表す文字列。

6.6 フォーカス

6.6.1 導入

HTMLユーザーインターフェイスは典型的に、フォームコントロール、スクロール可能領域、リンク、ダイアログボックス、ブラウザータブなど、複数の対話的なウィジットから成る。これらウィジェットは、他(たとえば、リンク、フォームコントロール)を含むもの(たとえば、ブラウザータブ、ダイアログボックス)をもつ、階層構造を形成する。

キーボードを使用するインターフェイスと情報交換する場合、アクティブなウィジェットから、フォーカスされると呼ばれる、対話的なウィジェットの階層構造を通して、キー入力はシステムから流れる。

グラフィカル環境で動作するブラウザータブにおいて動作するHTMLアプリケーションを考えてみる。このアプリケーションが、いくつかのテキストコントロールおよびリンクをもつページを持ち、それ自身がテキストコントロールとボタンを持った、モーダルダイアログを表示していると想定する。

このシナリオにおいて、その子の間でHTMLアプリケーションを含むブラウザータブを持つだろう、フォーカス可能なウィジェットの階層構造は、ブラウザーウィンドウを含むかもしれない。タブ自身は、ダイアログと同様に、その子として、様々なリンクおよびテキストコントロールを持つだろう。ダイアログ自身は、その子として、テキストコントロールおよびボタンを持つだろう。

この例でフォーカスをもつウィジェットがダイアログボックスでテキストコントロールであった場合、キー入力は、グラフィカルシステムから①ウェブブラウザー、②タブ、③ダイアログ、そして最後に④テキストコントロールへ流される。

キーボードイベントは、常にこのフォーカスされた要素で対象にされる。

6.6.2 データモデル

トップレベルトラバーサブルは、オペレーティングシステムからチャネルされたキーボード入力(おそらくアクティブな文書子孫ナビゲート可能の1つがターゲット)を受け取ることができる場合、システムフォーカスを持つ。

トップレベル横断可能は、そのシステム可視状態が"visible"である場合、 ユーザーアテンションを持ち、そしてシステムフォーカスを持つか、またはそれに直接関連するユーザーエージェントウィジェットが、オペレーティングシステムから送られたキーボード入力を受け取ることができるかのいずれかである。

ブラウザーウィンドウがフォーカスを失うと、ユーザーアテンションは失われるが、一方でシステムのフォーカスもまた、ロケーションバーなど、ブラウザーウィンドウ内の他のシステムウィジェットを失われる可能性がある。

Document dは、d完全にアクティブであり、かつdノートナビゲート可能トップレベル横断可能ユーザーアテンションがある場合、ユーザーアテンションをもつトップレベル横断可能の完全にアクティブの子孫である。

用語フォーカス可能領域は、そのようなキーボード入力の対象になる可能性があるインターフェイスの領域を指すために使用される。フォーカス可能領域は、要素、要素の一部、またはユーザーエージェントによって処理される他の領域となることができる。

フォーカス可能領域は、DOMでフォーカス可能領域の位置を表すNodeオブジェクトである、DOMアンカーを持つ。(フォーカス可能領域Node自身である場合、それはそれ自身のDOM anchorである。)フォーカス可能領域を表すために他のDOMオブジェクトが存在しない場合、DOMアンカーは、フォーカス可能領域に適するようないくつかのAPIで使用される。

以下のテーブルは、どのオブジェクトがフォーカス可能領域となることができるかを説明する。左の列におけるセルは、フォーカス可能領域となることができるオブジェクトを説明する。右の列におけるセルは、この要素に対するDOMアンカーを説明する。(両方の列をまたぐセルは、非規範的な例である。)

フォーカス可能領域DOMアンカー
次のすべての基準を満たす要素: 要素自身。

iframedialog<input type=text>、時として<a href="">(プラットフォーム慣習に依存する)。

レンダリングされているおよび不活性でないimg要素に関連するイメージマップにおけるarea要素の形状。img要素

次の例において、それぞれ画像の、area要素は2つの形状を作成する。最初の形状のDOMアンカーは、最初のimg要素であり、2つめの形状のDOM anchorは、2つめのimg要素である。

<map id=wallmap><area alt="Enter Door" coords="10,10,100,200" href="door.html"></map>
...
<img src="images/innerwall.jpeg" alt="There is a white wall here, with a door." usemap="#wallmap">
...
<img src="images/outerwall.jpeg" alt="There is a red wall here, with a door." usemap="#wallmap">
要素のサブウィジェットを提供されるユーザーエージェントは、レンダリングされているかつ実際に無効または不活性でない。フォーカス可能領域がサブウィジェットとなる要素。

video要素に対するユーザーに公開されるユーザーインターフェイスにおけるコントロール<input type=number>のスピンコントロールバージョンにおけるアップ・ダウンボタン、キーボード入力を用いた開くまたは閉じるために要素を有効にするdetails要素のレンダリングの一部。

レンダリングされているかつ不活性でない要素のスクロール可能な領域。スクロール可能な領域のスクロールが作成されたボックスに対する要素

CSS 'overflow'プロパティの'scroll'値が典型的にスクロール可能領域を作成する。

非nullのブラウジングコンテキストがあり、不活性ではないDocumentビューポートビューポートが作成されたDocument

iframeのコンテンツ。

特にアクセシビリティを支援するために、またはプラットフォームの規則によりよく一致させるために、ユーザーエージェントによってフォーカス可能な領域であると判断される他の要素または要素の一部。 要素。

ユーザーエージェントは、すべてのリストアイテムの箇条書きをシーケンシャルにフォーカス可能にして、その結果ユーザーがリストをより簡単にナビゲートできるようにすることができる。

同様に、ユーザーエージェントは、title属性をもつすべての要素をシーケンシャルにフォーカス可能にして、その結果それら属性の助言情報にアクセスすることができる。

ナビゲート可能なコンテナーiframeなど)は、フォーカス可能な領域であるが、ナビゲート可能なコンテナーに送られるキーイベントは、コンテンツナビゲート可能アクティブな文書にすぐに送られる。 同様に、シーケンシャルフォーカスナビゲーションにおいて、ナビゲート可能なコンテナーは基本的に、コンテンツナビゲート可能アクティブ文書のプレースホルダーとしてのみ機能する。


Documentの1つのフォーカス可能な領域は、文書のフォーカスされた領域として指定される。どのコントロールがそのように呼ばれるかは時間とともに変化し、この仕様におけるアルゴリズムに基づく。

たとえ文書が完全にアクティブでなくかつユーザーに表示されないとしても、文書のフォーカスされた領域を保持できる。文書の完全にアクティブな状態が変化しても、文書のフォーカスされた領域は同じままとなる。

The currently focused area of a top-level traversable traversable is the focusable area-or-null returned by this algorithm:

  1. If traversable does not have system focus, then return null.

  2. Let candidate be traversable's active document.

  3. While candidate's focused area is a navigable container with a non-null content navigable: set candidate to the active document of that navigable container's content navigable.

  4. If candidate's focused area is non-null, set candidate to candidate's focused area.

  5. candidateを返す。

The current focus chain of a top-level traversable traversable is the focus chain of the currently focused area of traversable, if traversable is non-null, or an empty list otherwise.

An element that is the DOM anchor of a focusable area is said to gain focus when that focusable area becomes the currently focused area of a top-level traversable. When an element is the DOM anchor of a focusable area of the currently focused area of a top-level traversable, it is focused.

6.6.3 tabindex属性

Global_attributes/tabindex

Support in all current engines.

Firefox1.5+Safari4+Chrome1+
Opera?Edge79+
Edge (Legacy)12+Internet ExplorerYes
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android?

tabindexコンテンツ属性は、著者が、DOMアンカーとして要素を持つ要素および領域をフォーカス可能領域にする、シーケンシャルフォーカス可能にすることを許可または防止する、ならびにシーケンシャルフォーカスナビゲーションの相対的な順序を決定することを可能にする。

名前"tab index"は、フォーカス可能な要素を通してナビゲートするためのTabキーの一般的な使用方法に由来する。"tabbing"(タブ移動)という用語は、シーケンシャルフォーカス可能フォーカス可能領域を前に進めることを指す。

tabindex属性が指定される場合、妥当な整数である値を持たなければならない。正の数値は、要素のフォーカス可能領域の相対的な位置をシーケンシャルフォーカスナビゲーション順序で指定し、負の数値はコントロールがシーケンシャルフォーカス可能でないことを示す。

0または-1以外の値を使用している場合、開発者は、これが正しく行うために複雑になるよう、自身のtabindex属性に対して用心すべきである。

以下に、可能なtabindex属性値の動作の概要を提供する。

省略(または非整数値)
ユーザーエージェントは、要素がフォーカス可能かどうかを決定する。もしそうであるならば、その要素がシーケンシャルフォーカス可能またはクリックフォーカス可能(もしくはその両方)かを決定する。
−1(または他の負の整数値)
要素がフォーカス可能になり、著者がその要素をクリックフォーカス可能にするが、シーケンシャルフォーカス可能にしないことを示す。ユーザーエージェントは、たとえばプラットフォームの規則に従った特定の要素タイプ、またはキーボードのみのユーザーのために、クリックおよびシーケンシャルフォーカスの可能性に関するこの設定を無視する場合がある。
0
要素をフォーカス可能にし、著者がその要素をクリックフォーカス可能シーケンシャルフォーカス可能の両方を好むことを示す。ユーザーエージェントは、クリックおよびシーケンシャルフォーカスのこの設定を無視する場合がある。
正の整数値
0と同じように動作するが、さらに、tabindex順のフォーカスナビゲーションスコープ内で相対的な順序を作成するため、tabindex属性値がより大きい要素は後から来る。

tabindex属性は、要素をフォーカス不可にするために使用できないことに注意する。ページ著者ができる唯一の方法は、要素を無効にする、または要素を不活性にすることである。

6.6.4 フォーカス管理API

documentOrShadowRoot.activeElement

キーイベントが送られるまたは送る文書における最も深い要素を返す。大まかにいって、これは文書におけるフォーカスされた要素である。

このAPIために、子ナビゲート可能がフォーカスされるとき、そのコンテナーアクティブな文書内でフォーカスされる。 たとえば、ユーザーがiframeでフォーカスをテキストコントロールに移動する場合、iframeiframenode documentにおいてactiveElement APIによって返される要素である。

同様に、フォーカスされた要素がdocumentOrShadowRootとは異なるノードツリーにあるとき、documentOrShadowRootがフォーカスされた要素のシャドウを含む包含祖先である場合、返される要素はdocumentOrShadowRootと同じノードツリーにあるホストになり、そうでない場合はnullになる。

document.hasFocus()

キーイベントが文書を通してまたは文書に向かって送られる場合にtrueを返し、そうでなければfalseを返す。大まかにいって、これは文書、この内側でネストされた文書、フォーカスされていることに対応する。

window.focus()

可能であれば、フォーカスをウィンドウのナビゲート可能に移動する。

element.focus([ { preventScroll: true } ])

フォーカスを要素に移動する。

要素がナビゲート可能なテキストコンテナーである場合、代わりにナビゲート可能なコンテンツにフォーカスを移動する。

デフォルトでは、このメソッドはまた要素をビューにスクロールする。preventScrollオプションを指定してtrueに設定すると、この動作が防止される。

element.blur()

フォーカスをビューポートに移動する。このメソッドの使用は奨められない。ビューポートにフォーカスしたい場合、Document文書要素上のfocus()メソッドを呼び出す。

見苦しいフォーカスリングを発見する場合、フォーカスリングを非表示にするためにこの方法を使用してはならない。代わりに、'outline'プロパティを上書きするために:focus-visible疑似クラスを使用し、要素がフォーカスされるものを表示する別の方法を提供する。代替フォーカススタイルが利用可能にならないか、ページが主にキーボードを使用してページをナビゲートする人に対して著しく使用可能にならないか、ページをナビゲートするのに役立つフォーカスアウトラインを使う人の視覚を減少させないかどうかに注意する。

たとえば、textarea要素からアウトラインを隠し、代わりにフォーカスを示すために黄色の背景を使用するために、次を使うことができる:

textarea:focus-visible { outline: none; background: yellow; color: black; }

6.6.5 autofocus属性

autofocusコンテンツ属性は、著者にページがロードされるとすぐに要素にフォーカスされることを示すのを可能にし、ユーザーは重要な要素に手動でフォーカスすることなく入力を開始できる。

popover属性が設定されているdialog要素またはHTML要素内部の要素にautofocus属性が指定される場合、ダイアログまたはポップオーバーが表示されたときにフォーカスされる。

autofocus属性は真偽属性である。

To find the nearest ancestor autofocus scoping root element given an Element element:

  1. If element is a dialog element, then return element.

  2. If element's popover attribute is not in the no popover state, then return element.

  3. Let ancestor be element.

  4. While ancestor has a parent element:

    1. Set ancestor to ancestor's parent element.

    2. If ancestor is a dialog element, then return ancestor.

    3. If ancestor's popover attribute is not in the no popover state, then return ancestor.

  5. Return ancestor.

両方がautofocus属性を指定される同じ直近の祖先オートフォーカス範囲のルート要素をもつ2つの要素が存在してはならない。

次の断片において、文書が読み込まれるとき、テキストコントロールにフォーカスされる。

<input maxlength="256" name="q" value="" autofocus>
<input type="submit" value="Search">

autofocus属性は、フォームコントロールだけでなく、すべての要素に適用される。 これにより、次のような例が可能になる:

<div contenteditable autofocus>Edit <strong>me!</strong><div>

6.7 キーボードショートカットの割り当て

6.7.1 導入

アクティブにされるまたはフォーカスさせることができる各要素はaccesskey属性を使用して、それをアクティブにするための単一のキーの組み合わせを割り当てることができる。

正確なショートカットは、ユーザーエージェントによって決定され、ユーザーのキーボードに関する情報に基づき、どのキーボードショートカットが既にプラットフォーム上に存在し、他にどのようなショートカットがページ上で指定され、ガイドとしてaccesskey属性に提供された情報を使用する。

関連するキーボードショートカットが多種多様な入力デバイスで利用可能であることを確実にするために、著者はaccesskey属性で多数の選択肢を提供できる。

各選択肢は、文字または数字のような、単一の文字で構成される。

ユーザーエージェントは、キーボードショートカットの一覧をユーザーに提供できるが、著者は行うことも推奨される。accessKeyLabel IDL属性は、ユーザーエージェントによって割り当てられた実際のキーの組み合わせを表す文字列を返す。

この例において、著者はショートカットキーを使用して呼び出すことができるボタンを提供してきた。フルキーボードをサポートするために、著者は可能なキーとして"C"を提供している。テンキーのみを搭載したデバイスをサポートするために、著者は別の可能なキーとして"1"を提供している。

<input type=button value=Collect onclick="collect()"
       accesskey="C 1" id=c>

ショートカットキーが何であるかをユーザーに伝えるために、著者は明示的にボタンのラベルにキーの組み合わせを追加するために選択しているここでのこのスクリプトを持つ。

function addShortcutKeyLabel(button) {
  if (button.accessKeyLabel != '')
    button.value += ' (' + button.accessKeyLabel + ')';
}
addShortcutKeyLabel(document.getElementById('c'));

異なるプラットフォーム上のブラウザーは、たとえ同じキーの組み合わせであっても、そのプラットフォーム上で普及している規則に基づいて異なるラベルを表示する。たとえば、キーの組み合わせが、Controlキー、Shiftキー、および文字Cである場合、Macのブラウザーが"^⇧C"を表示するかもしれない一方で、Windowsのブラウザーは"Ctrl+Shift+C"を表示するかもしれない。一方でEmacsのブラウザーは単に"C-C"を表示するかもしれない。同様に、キーの組み合わせがAltキーとEscキーである場合、Windowsは"Alt+Esc"を使用するかもしれず、Macは"⌥⎋"を使用するかもしれず、Emacsのブラウザーは、"M-ESC"または"ESC ESC"を使用するかもしれない。

したがって、一般に、accessKeyLabel IDL属性から返された値を解析しようとするのは賢明ではない。

6.7.2 accesskey属性

Global_attributes/accesskey

Support in all current engines.

Firefox1+Safari4+Chrome1+
Opera?Edge79+
Edge (Legacy)12+Internet ExplorerYes
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android?

すべてのHTML要素は、accesskeyコンテンツ属性の設定を持ってもよい。accesskey属性値は、要素をアクティブにするまたはフォーカスするキーボードショートカットを作成するためのガイドとして、ユーザーエージェントによって使用される。

指定される場合、値は、順序付きの一意な空白区切りトークンの集合でなければならない。これらのトークンはいずれも別のトークンと同一でなく、それぞれが正確に1コードポイント長さでなければならない。

次の例において、サイトを熟知するキーボードユーザーがより迅速に関連するページに移動できるよう、さまざまなリンクがアクセスキーとともに与えられる:

<nav>
 <p>
  <a title="Consortium Activities" accesskey="A" href="/Consortium/activities">Activities</a> |
  <a title="Technical Reports and Recommendations" accesskey="T" href="/TR/">Technical Reports</a> |
  <a title="Alphabetical Site Index" accesskey="S" href="/Consortium/siteindex">Site Index</a> |
  <a title="About This Site" accesskey="B" href="/Consortium/">About Consortium</a> |
  <a title="Contact Consortium" accesskey="C" href="/Consortium/contact">Contact</a>
 </p>
</nav>

次の例において、検索フィールドは2つの可能なアクセスキー、"s"と"0"(この順番で)が与えられる。テンキー付きの小さなデバイス上のユーザーエージェントは単なる簡素なキー0を選ぶかもしれないが、フルキーボードを搭載したデバイスでのユーザーエージェントは、ショートカットキーとしてCtrl + Alt + Sを選ぶかもしれない:

<form action="/search">
 <label>Search: <input type="search" name="q" accesskey="s 0"></label>
 <input type="submit">
</form>

次の例において、ボタンは説明可能なアクセスキーを持つ。このスクリプトは次に、ユーザーエージェントが選択したキーの組み合わせを通知するためにボタンのラベルの更新を試みる。

<input type=submit accesskey="N @ 1" value="Compose">
...
<script>
 function labelButton(button) {
   if (button.accessKeyLabel)
     button.value += ' (' + button.accessKeyLabel + ')';
 }
 var inputs = document.getElementsByTagName('input');
 for (var i = 0; i < inputs.length; i += 1) {
   if (inputs[i].type == "submit")
     labelButton(inputs[i]);
 }
</script>

あるユーザーエージェントにおいて、ボタンのラベルは"Compose(⌘N)"になるかもしれない。別のものにおいて、これは"Compose(Alt+⇧+1)"になるかもしれない。ユーザーエージェントがキーを割り当てない場合、単に"Compose"になる。正確な文字列は割り当てられるアクセスキーが何であるか、およびどのようにユーザーエージェントがそのキーの組み合わせを表すかに依存する。

6.8 編集

6.8.1 編集可能な文書領域を作成する:contenteditableコンテンツ属性

HTMLElement/contentEditable

Support in all current engines.

Firefox3+Safari3+Chrome1+
Opera9+Edge79+
Edge (Legacy)12+Internet Explorer5.5+
Firefox Android?Safari iOS1+Chrome Android?WebView Android?Samsung Internet?Opera Android10.1+

Global_attributes/contenteditable

Support in all current engines.

Firefox3+Safari4+Chrome1+
Opera9+Edge79+
Edge (Legacy)12+Internet Explorer5.5+
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android?

The contenteditable content attribute is an enumerated attribute with the following keywords and states:

キーワード状態概要
truetrueThe element is editable.
(空文字列)
falsefalseThe element is not editable.
plaintext-onlyplaintext-onlyOnly the element's raw text content is editable; rich formatting is disabled.

The attribute's missing value default and invalid value default are both the inherit state. The inherit state indicates that the element is editable (or not) based on the parent element's state.

たとえば、ユーザーがHTMLを使用する記事を書くことが期待される、新しい記事を公開するためにformおよびtextareaを持つページを考えてみる:

<form method=POST>
 <fieldset>
  <legend>New article</legend>
  <textarea name=article>&lt;p>Hello world.&lt;/p></textarea>
 </fieldset>
 <p><button>Publish</button></p>
</form>

スクリプトを有効にする場合、textarea要素は、contenteditable属性を使用して、代わりにリッチテキストコントロールに置き換えることができる:

<form method=POST>
 <fieldset>
  <legend>New article</legend>
  <textarea id=textarea name=article>&lt;p>Hello world.&lt;/p></textarea>
  <div id=div style="white-space: pre-wrap" hidden><p>Hello world.</p></div>
  <script>
   let textarea = document.getElementById("textarea");
   let div = document.getElementById("div");
   textarea.hidden = true;
   div.hidden = false;
   div.contentEditable = "true";
   div.oninput = (e) => {
     textarea.value = div.innerHTML;
   };
  </script>
 </fieldset>
 <p><button>Publish</button></p>
</form>

たとえば挿入リンクを挿入する機能は、document.execCommand()APIを使用する、またはSelectionAPIおよび他のDOM APIを使用して実装することができる。[EXECCOMMAND] [SELECTION] [DOM]

contenteditable属性はまた、大きな効果を使用することができる:

<!doctype html>
<html lang=en>
<title>Live CSS editing!</title>
<style style=white-space:pre contenteditable>
html { margin:.2em; font-size:2em; color:lime; background:purple }
head, title, style { display:block }
body { display:none }
</style>
element.contentEditable [ = value ]

Returns "true", "plaintext-only", "false", or "inherit", based on the state of the contenteditable attribute.

その状態を変更する設定が可能である。

新しい値がこれらの文字列のいずれかでない場合、"SyntaxError" DOMExceptionを投げる。

element.isContentEditable

要素が編集可能な場合にtrueを返す。そうでなければfalseを返す。

6.8.2 文書全体を編集可能にする:designModeのゲッターおよびセッター

document.designMode [ = value ]

文書が編集可能である場合に"on"を返し、ない場合に"off"を返す。

文書の現在の状態を変更する設定が可能である。これは、文書をフォーカスし、その文書で文書の選択をリセットする。

6.8.3 ページ内編集者のためのベストプラクティス

著者は、もともと値'pre-wrap'へこれら編集のメカニズムを介して作成された編集ホストおよびマークアップ上の'white-space'プロパティを設定することを奨める。デフォルトのHTML空白処理は、あまりWYSIWYG編集に向かず、そして'white-space'がデフォルト値のままである場合、いくつかのコーナーの場合において、行の折り返しは正しく動作しない。

デフォルト'normal'値が代わりに使用される場合に発生する問題の例として、単語の間に2つのスペース(ここでは"␣"によって表される)とともに、"yellow␣␣ball"と入力したユーザーの場合を考える。'white-space'のデフォルト値('normal')のための場所での編集規則ともに、結果のマークアップは、"yellow&nbsp; ball"または"yellow &nbsp;ball"のいずれかで構成される。すなわち、2つの単語間の非開票スペースに加えて、通常スペースが存在する。'white-space'に対する'normal'値は共に相殺するために隣接する通常スペースを必要とするため、これは必要である。

前者の場合において、たとえ行の末尾で"yellow"単独で一致するとしても、"yellow⍽"は次の行("⍽"は非改行スペースを表すためにここで使用されている)に折り返す。後者の場合において、行の先頭に包まれる場合、"⍽ball"は非改行スペース由来の可視インデントを持つだろう。

しかし、'white-space'が'pre-wrap'に設定される場合、編集規則は、代わりに単に単語間に2つの通常のスペースを置き、2つの単語が行末で分割されるべきであり、スペースはレンダリングから削除されてきれいになる。

6.8.4 スペルと文法チェック

Global_attributes/spellcheck

Support in all current engines.

FirefoxYesSafariYesChrome9+
OperaYesEdge79+
Edge (Legacy)12+Internet Explorer11
Firefox Android57+Safari iOS9.3+Chrome Android47+WebView Android?Samsung Internet?Opera Android37+

The spellcheck attribute is an enumerated attribute with the following keywords and states:

キーワード状態概要
truetrueSpelling and grammar will be checked.
(空文字列)
falsefalseSpelling and grammar will not be checked.

The attribute's missing value default and invalid value default are both the default state. The default state indicates that the element is to act according to a default behavior, possibly based on the parent element's own spellcheck state, as defined below.

element.spellcheck [ = value ]

要素がスペルや文法チェックを持つ場合はtrueを返す。そうでなければfalseを返す。

デフォルトを上書きしてspellcheckコンテンツ属性を設定するための、設定が可能である。

この仕様は、スペルや文法チェッカーに対するユーザーインターフェイスを定義しない。ユーザーエージェントはオンデマンドチェックを提供するかもしれず、チェックが有効である間に連続的なチェックを実行するかもしれず、または他のインターフェイスを使用するかもしれない。

6.8.5 Writing suggestions

User agents offer writing suggestions as users type into editable regions, either in form controls (e.g., the textarea element) or in elements in an editing host.

The writingsuggestions content attribute is an enumerated attribute with the following keywords and states:

キーワード状態概要
truetrueWriting suggestions should be offered on this element.
(The empty string)
falsefalseWriting suggestions should not be offered on this element.

The attribute's missing value default is the default state. The default state indicates that the element is to act according to a default behavior, possibly based on the parent element's own writingsuggestions state, as defined below.

The attribute's invalid value default is the true state.

element.writingSuggestions [ = value ]

Returns "true" if the user agent is to offer writing suggestions under the scope of the element; otherwise, returns "false".

Can be set, to override the default and set the writingsuggestions content attribute.


User agents should only offer suggestions within an element's scope if the result of running the following algorithm given element returns true:

  1. If the user has disabled writing suggestions, then return false.

  2. If none of the following conditions are true:

    then return false.

  3. If element has an inclusive ancestor with a writingsuggestions content attribute that's not in the default and the nearest such ancestor's writingsuggestions content attribute is in the false state, then return false.

  4. Otherwise, return true.

This specification does not define the user interface for writing suggestions. A user agent could offer on-demand suggestions, continuous suggestions as the user types, inline suggestions, autofill-like suggestions in a popup, or could use other interfaces.

6.8.6 自動大文字化

モバイルデバイス上の仮想キーボードや音声入力など、テキストを入力するいくつかの方法では、文の最初の文字を自動的に大文字にすることでユーザーを支援することがある(この規則で言語でテキストを構成する場合)。自動大文字化を実装する仮想キーボードは、自動大文字にすべき文字を入力しようとするとき、大文字の文字を表示するように自動的に切り替えるかもしれない(ただし、ユーザーはその文字を小文字に切り替え可能である)。例えば音声入力など、他の入力の種類は、ユーザーが最初に介入するオプションを与えないような方法で自動大文字化を行ってもよい。autocapitalize属性は、著者がそのような振る舞いを制御するのを可能にする。

典型的に実装されるように、autocapitalize属性は、物理キーボードで入力するときの動作に影響しない。(この理由のために、場合によっては自動大文字化の動作を上書きしたり、最初の入力の後にテキストを編集することをユーザーの能力と同様に、属性をいかなる種類の入力検証にも当てにしてはならない。

ホストされている編集可能領域の自動大文字化動作を制御するために編集ホスト上で、その要素にテキストを入力するための動作を制御するためにinputもしくはtextarea要素の上で、またはform要素に関連付けられたすべての自動大文字継承要素のデフォルトの動作を制御するためにform要素上でautocapitalize属性を使用することができる。

autocapitalize属性は、type属性がURLEmail、またはPassword状態のいずれかにあるinput要素に対して、自動大文字化を有効にすることはない。

自動大文字化処理モデルは、以下のように定義される5つの自動大文字化ヒントの中から選択することに基づく:

default

ユーザーエージェントおよびインプットメソッドは、自動大文字化を有効にするかどうかを独自に決定すべきである。

none

自動大文字化は適用されるべきではない(すべての文字は小文字をデフォルトにすべきである)。

sentences

各文の最初の文字は大文字をデフォルトにすべきである。他のすべての文字は小文字をデフォルトにすべきである。

words

各単語の最初の文字は大文字をデフォルトにすべきである。他のすべての文字は小文字をデフォルトにすべきである。

characters

全ての文字は大文字をデフォルトにすべきである。

Global_attributes/autocapitalize

Support in all current engines.

Firefox111+SafariNoChrome43+
Opera?Edge79+
Edge (Legacy)?Internet Explorer?
Firefox Android?Safari iOS5+Chrome Android?WebView Android?Samsung Internet?Opera Android?

autocapitalize属性は、状態が可能な自動大文字ヒントである列挙属性である。属性の状態で指定された自動大文字化ヒントは、ユーザーエージェントの動作を通知する、使用済みの自動大文字化ヒントを形成するための他の考慮事項と組み合わされる。この属性のキーワードと状態マッピングは次のとおり:

キーワード状態
offnone
none
onsentences
sentences
wordswords
characterscharacters

The attribute's missing value default is the default state, and its invalid value default is the sentences state.

element.autocapitalize [ = value ]

要素の現在の自動大文字化状態を返す。設定されていない場合は空文字列を返す。form要素から状態を継承するinput要素とtextarea要素の場合、これはform要素の自動大文字化状態を返すが、編集可能領域の要素の場合、これは(この要素が実際に編集ホストでない限り)編集ホストの自動大文字化状態を返さないことに注意すること。

autocapitalizeコンテンツ属性を設定する(そしてそれによって要素の自動大文字化動作を変化させる)ことで、設定が可能である。

6.8.7 入力モダリティ:inputmode属性

ユーザーエージェントは、フォームコントロール(textarea要素の値など)で、または編集ホストcontenteditableなど)における要素でinputmode属性をサポートすることができる。

Global_attributes/inputmode

Support in all current engines.

Firefox95+SafariNoChrome66+
Opera?Edge79+
Edge (Legacy)?Internet ExplorerNo
Firefox Android79+Safari iOS12.2+Chrome Android?WebView Android?Samsung Internet?Opera Android?

inputmodeコンテンツ属性は、ユーザーがコンテンツを入力する際に最も参考になる入力メカニズムの種類を指定する列挙属性である。

キーワード説明
noneユーザーエージェントは仮想キーボードを表示すべきではない。このキーワードは、独自のキーボードコントロールをレンダリングするコンテンツに役立つ。
textユーザーエージェントは、ユーザーのロケールでテキスト入力が可能な仮想キーボードを表示すべきである。
telユーザーエージェントは、電話番号入力が可能な仮想キーボードを表示すべきであある。これは、数字0〜9、"#"文字、および"*"文字のキーを含むべきである。一部のロケールで、これはまた、アルファベットのニーモニックラベル(たとえば、米国で、"2"キーはまた、歴史的に文字A、B、およびCで標識されている)を含むことができる。
urlユーザーエージェントは、"/"と"."文字、"www"や".com"のようなドメイン名の中で見つかった文字列を簡単に入力するための、URLの入力を補助するためのキーとともに、ユーザーのロケールでテキスト入力が可能な仮想キーボードを表示すべきである。
emailユーザーエージェントは、"@"文字および"."文字のような、電子メールアドレスの入力を補助するためのキーとともに、ユーザーのロケールでテキスト入力が可能な仮想キーボードを表示すべきである。
numericユーザーエージェントは、数字入力が可能な仮想キーボードを表示すべきであある。このキーワードは、PIN入力に便利である。
decimalユーザーエージェントは、小数入力が可能な仮想キーボードを表示すべきであある。ロケールの数値キーおよびフォーマットセパレーターを表示すべきである。
searchユーザーエージェントは、検索に最適化された仮想キーボードを表示すべきである。

6.8.8 入力モダリティ:enterkeyhint属性

ユーザーエージェントは、フォームコントロール(textarea要素の値など)で、または編集ホストcontenteditableなど)における要素でenterkeyhint属性をサポートすることができる。

Global_attributes/enterkeyhint

Support in all current engines.

Firefox94+Safari13.1+Chrome77+
Opera66+Edge79+
Edge (Legacy)?Internet ExplorerNo
Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android57+

enterkeyhintコンテンツ属性は、仮想キーボードのEnterキーに表示するアクションラベル(またはアイコン)を指定する列挙属性である。これにより、ユーザーにとってより役立つようにするために、著者はEnterキーの表示をカスタマイズを可能にする。

キーワード説明
enterユーザーエージェントは、典型的には新しい行を挿入する、操作'enter'の合図を提示すべきである。
doneユーザーエージェントは、典型的には入力するものがもう何もなく、そして input method editor (IME)は閉じられることを意味する、操作'done'の合図を提示すべきである。
goユーザーエージェントは、典型的にはユーザーがタイプしたテキストのターゲットにユーザーを連れて行くことを意味する、操作'go'の合図を提示すべきである。
nextユーザーエージェントは、典型的にはテキストを受け付ける次のフィールドにユーザーを連れて行く、操作'next'の合図を提示すべきである。
previousユーザーエージェントは、典型的にはテキストを受け入れる前のフィールドにユーザーを連れて行く、操作'previous'の合図を提示すべきである。
searchユーザーエージェントは、典型的にはユーザーがタイプしたテキストの検索の結果にユーザーを連れて行く、操作「検索」の合図を提示すべきである。
sendユーザーエージェントは、典型的にはテキストをそのテキストのターゲットに配信する、操作'send'の合図を提示すべきである。

6.9 ページ内検索

6.9.1 導入

このセクションは、ページ内検索を定義する。これは、ユーザーが特定の情報に対してページのコンテンツを検索できるようにする一般的なユーザーエージェントのメカニズムである。

ページ内検索機能へのアクセスは、ページ内検索インターフェイスを介して提供される。これはユーザーエージェントが提供するユーザーインターフェイスであり、ユーザーが入力と検索のパラメーターを指定できるようする。このインターフェイスは、ショートカットまたはメニュー選択の結果として表示される。

ページ内検索インターフェイスのテキスト入力と設定の組み合わせは、ユーザーのクエリーを表す。これは通常、ユーザーが検索したいテキストと、オプションの設定(例えば、検索を単語に限定する機能など)が含まれる。

ユーザーエージェントは、与えられたクエリーのページコンテンツを処理し、0個以上のマッチを識別する。これはユーザークエリーを満たすコンテンツ範囲である。

マッチの1つがアクティブなマッチとしてユーザーに識別される。 それはハイライトされ、スクロールして表示される。ユーザーは、ページ内検索インターフェイスを使用してアクティブなマッチを前進させることにより、マッチをナビゲートできる。

Issue #3539は、ページ内検索が現在指定されていないwindow.find() APIの基礎となる方法の標準化を追跡する。

6.9.2 detailshidden=until-foundとの相互作用

ページ内検索が一致するものの検索を開始するとき、 open属性が設定されていないページ内のすべてのdetails要素は、ページ内検索が検索できるようにするために、open属性を変更せずに、2番目のスロットのスキップされたコンテンツにアクセスできるようにすべきである。Similarly, all HTML elements with the hidden attribute in the hidden until found state should have their skipped contents become accessible without modifying the hidden attribute in order to make find-in-page able to search through them. After find-in-page finishes searching for matches, the details elements and the elements with the hidden attribute in the hidden until found state should have their contents become skipped again. このプロセス全体は同期的に行われなければならない(したがって、ユーザーや著者のコードを監視することはできない)。[CSSCONTAIN]

When find-in-page chooses a new active match, perform the following steps:

  1. Let node be the first node in the active match.

  2. Queue a global task on the user interaction task source given node's relevant global object to run the following steps:

    1. Run the ancestor details revealing algorithm on node.

    2. Run the ancestor hidden-until-found revealing algorithm on node.

When find-in-page auto-expands a details element like this, it will fire a toggle event. As with the separate scroll event that find-in-page fires, this event could be used by the page to discover what the user is typing into the find-in-page dialog. If the page creates a tiny scrollable area with the current search term and every possible next character the user could type separated by a gap, and observes which one the browser scrolls to, it can add that character to the search term and update the scrollable area to incrementally build the search term. By wrapping each possible next match in a closed details element, the page could listen to toggle events instead of scroll events. This attack could be addressed for both events by not acting on every character the user types into the find-in-page dialog.

6.9.3 選択との相互作用

ページ内検索プロセスは、文書のコンテキストで呼び出され、その文書の選択に影響を与えることがある。 具体的には、アクティブなマッチを定義する範囲が、現在の選択を決定することがある。しかし、この選択の更新は、ページ内検索プロセスのさまざまな時点で発生することがある(たとえば、ページ内検索インターフェイスの終了時、またはアクティブなマッチの範囲の変更時)。

6.10 Close requests and close watchers

6.10.1 Close requests

In an implementation-defined (and likely device-specific) manner, a user can send a close request to the user agent. This indicates that the user wishes to close something that is currently being shown on the screen, such as a popover, menu, dialog, picker, or display mode.

Some example close requests are:

On platforms where Esc is the close request, the user agent will first fire an appropriately-initialized keydown and keyup event sequence. If the web developer cancels the keyup event by calling preventDefault(), then nothing further happens. But if the event fires without being canceled, then the user agent proceeds to process close watchers.

On platforms where a back button is a potential close request, no event is involved, so when the back button is pressed, the user agent proceeds directly to process close watchers. If there is an active close watcher, then that will get triggered. If there is not, then the user agent can interpret the back button press in another way, for example as a request to traverse the history by a delta of −1.

6.10.2 The CloseWatcher interface

watcher = new CloseWatcher()
watcher = new CloseWatcher({ signal })

Creates a new CloseWatcher instance.

If the signal option is provided, then watcher can be destroyed (as if by watcher.destroy()) by aborting the given AbortSignal.

If any close watcher is already active, and the Window does not have history-action activation, then the resulting CloseWatcher will be closed together with that already-active close watcher in response to any close request. (This already-active close watcher does not necessarily have to be a CloseWatcher object; it could be a modal dialog element, or a popover generated by an element with the popover attribute.)

watcher.requestClose()

Acts as if a close request was sent targeting watcher, by first firing a cancel event, and if that event is not canceled with preventDefault(), proceeding to fire a close event before deactivating the close watcher as if watcher.destroy() was called.

This is a helper utility that can be used to consolidate cancelation and closing logic into the cancel and close event handlers, by having all non-close request closing affordances call this method.

watcher.close()

Immediately fires the close event, and then deactivates the close watcher as if watcher.destroy() was called.

This is a helper utility that can be used trigger the closing logic into the close event handler, skipping any logic in the cancel event handler.

watcher.destroy()

Deactivates watcher, so that it will no longer receive close events and so that new independent CloseWatcher instances can be constructed.

This is intended to be called if the relevant UI element is torn down in some other way than being closed.

The following are the event handlers (and their corresponding event handler event types) supported, as event handler IDL attributes, by all objects implementing the CloseWatcher interface:

イベントハンドラーイベントハンドラーイベント型
oncancelcancel
oncloseclose

If one wanted to implement a custom picker control, which closed itself on a user-provided close request as well as when a close button is pressed, the following code shows how one would use the CloseWatcher API to process close requests:

const watcher = new CloseWatcher();
const picker = setUpAndShowPickerDOMElement();

let chosenValue = null;

watcher.onclose = () => {
  chosenValue = picker.querySelector('input').value;
  picker.remove();
};

picker.querySelector('.close-button').onclick = () => watcher.requestClose();

Note how the logic to gather the chosen value is centralized in the CloseWatcher object's close event handler, with the click event handler for the close button delegating to that logic by calling requestClose().

The cancel event on CloseWatcher objects can be used to prevent the close event from firing, and the CloseWatcher from being destroying. A typical use case is as follows:

watcher.oncancel = async (e) => {
  if (hasUnsavedData) {
    e.preventDefault();

    const userReallyWantsToClose = await askForConfirmation("Are you sure you want to close?");
    if (userReallyWantsToClose) {
      hasUnsavedData = false;
      watcher.close();
    }
  }
};

For abuse prevention purposes, this event only fires if the page has history-action activation, which will be lost after any given close request. This ensures that if the user sends a close request twice in a row without any intervening user activation, the request definitely succeeds; the second request ignores the cancel event handler and immediately closes the CloseWatcher.

Combined, the above two examples show how requestClose() and close() differ. Because we used requestClose() in the click event handler for the close button, clicking that button will trigger the CloseWatcher's cancel event, and thus potentially ask the user for confirmation if there is unsaved data. If we had used close(), then this check would be skipped. Sometimes that is appropriate, but usually requestClose() is the better option for user-triggered close requests.

In addition to the user activation restrictions for cancel events, there is a more subtle form of user activation gating for CloseWatcher construction. If one creates more than one CloseWatcher without user activation, then the newly-created one will get grouped together with the most-recently-created close watcher, so that a single close request will close them both:

window.onload = () => {
  // This will work as normal: it is the first close watcher created without user activation.
  (new CloseWatcher()).onclose = () => { /* ... */ };
};

button1.onclick = () => {
  // This will work as normal: the button click counts as user activation.
  (new CloseWatcher()).onclose = () => { /* ... */ };
};

button2.onclick = () => {
  // These will be grouped together, and both will close in response to a single close request.
  (new CloseWatcher()).onclose = () => { /* ... */ };
  (new CloseWatcher()).onclose = () => { /* ... */ };
};

This means that calling destroy(), close(), or requestClose() properly is important. Doing so is the only way to get back the "free" ungrouped close watcher slot. Such close watchers created without user activation are useful for cases like session inactivity timeout dialogs or urgent notifications of server-triggered events, which are not generated in response to user activation.