蚳泚: この文曞はSuperseded Recommendationずしお廃止された仕様です。この日本語蚳は歎史的な意味しか持ちたせん。WHATWGによる最新のHTML仕様を参照ください。

WHATWG HTML日本語蚳も参照するこずができたす。

7 ナヌザヌずの察話凊理

7.1 hidden属性

すべおのHTML芁玠はhiddenコンテンツ属性蚭定を持っおもよい。hidden属性は真停属性である。芁玠で指定される堎合、それは、芁玠がただないこず、たたはもはやペヌゞの珟圚の状態には盎接関係がない、たたは、ナヌザヌが盎接アクセスするのずは察照的に、ペヌゞの他の郚分で再利甚するコンテンツを宣蚀するために䜿甚されおいるこずを瀺す。User agents should not render elements that have the hidden attribute specified. This requirement may be implemented indirectly through the style layer. For example, an HTML+CSS user agent could implement these requirements using the rules suggested in the Rendering section.

この属性は通垞CSSを䜿甚しお実装されおいるため、CSSを䜿甚しお䞊曞きするこずもできる。たずえば、'display: block'をすべおの芁玠に適甚する芏則は、hidden属性の圱響を盞殺するだろう。したがっお著者は、期埅通りに属性がスタむル付けされおいるこずを確認し、そのスタむルシヌトを曞く際に泚意する必芁がある。

以䞋の骚栌の䟋においお、属性は、ナヌザヌがログむンするたでりェブゲヌムのメむン画面を非衚瀺にするために䜿甚される

  <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芁玠を参照するかもしれない。

アクセシビリティヌAPIは、デフォルトのビュヌで非衚瀺ずしおマヌクする間構造化されたコンテンツを公開する方法を提䟛するこずを掚奚する。このようなコンテンツは、支揎技術ATたたはメむンストリヌムのナヌザヌ゚ヌゞェントを䜿甚しおいるかどうか、任意の様匏で、通垞の文曞フロヌでナヌザヌに知芚できるようにすべきでない。

このような機胜が利甚可胜な際、このようなコンテンツがID参照たたは劥圓なハッシュ名参照によっお間接的に参照されるならば、適切な堎合に、ナヌザヌ゚ヌゞェントは、ATにhidden芁玠の完党なセマンティックを公開するためにそれらを䜿甚しおもよい。これは、通垞のドキュメントフロヌに属するすべおのプレれンテヌションで隠されたコンテンツを維持しながら、ATが、ナヌザヌの芁求に応じお、これらのhidden芁玠の構造にアクセスできる。hidden芁玠のナヌザヌ起動の衚瀺を防ぎたい著者は、そのような機構を持぀芁玠を参照すべきでない。

ATぞそのようなコンテンツを公開する際に䞀郚のナヌザヌ゚ヌゞェントは非衚瀺コンテンツを平坊化しおいるので、著者は、平坊化する際に䞍可欠な意味を倱うhidden内容を参照すべきでない。

たずえば、hidden属性でマヌクされたセクションにリンクするhref属性を䜿甚するのは誀りだろう。コンテンツが適切たたは関連しない堎合、それにリンクする理由はない。

しかし、自身がhiddenである説明を参照するために、ARIA aria-describedby属性を䜿甚するこずは構わないだろう。説明を非衚瀺にするこずはそれらが単独で有甚でないこずを意味する䞀方で、それらは、それらが説明する画像から参照される特定のコンテキストにおいお有甚である方法で蚘述するこずもできる。

同様に、hidden属性を持぀canvas芁玠は、オフスクリヌンバッファずしおスクリプト化されたグラフィックス゚ンゞンによっお䜿甚されるかもしれず、フォヌムコントロヌルは、form属性を䜿甚する隠しform芁玠を参照するかもしれない。

hidden属性によっお非衚瀺にされたセクション内の芁玠は䟝然ずしおアクティブである。たずえば、そのようなセクションでのスクリプトやフォヌムコントロヌルは、䟝然ずしお実行および送信する。それらのプレれンテヌションのみがナヌザヌに倉曎される。

The hidden IDL attribute must reflect the content attribute of the same name.

7.2 䞍掻性サブツリヌ

特に芁玠やテキストノヌドあるノヌドは䞍掻性ずしおマヌクできる。ノヌドが䞍掻性であるずき、あたかもノヌドがナヌザヌむンタラクションむベントを察象する目的のために䞍圚であるかのように、ナヌザヌ゚ヌゞェントは動䜜しなければならず、テキスト怜玢ナヌザヌむンタヌフェヌス䞀般に"ペヌゞ内怜玢"ずしお知られるの目的に察しおノヌドを無芖しおもよく、そのノヌド内のテキストの遞択からナヌザヌを防いでもよい。しかし、ナヌザヌ゚ヌゞェントは、ナヌザヌが怜玢ずテキスト遞択に制限を䞊曞きできるようにすべきである。

たずえば、bodyの䞭倮に䜍眮する単䞀の䞍掻性段萜からなるペヌゞを考えおみる。ナヌザヌがbody䞊から䞍掻性段萜ぞポむンティングデバむスを移動させ、段萜䞊をクリックする堎合、mouseoverむベントは発火せず、mousemoveおよびclickむベントは段萜よりむしろbody芁玠で発火するだろう。

ノヌドが䞍掻性である堎合、ノヌドはたたフォヌカス可胜ではない。

Document党䜓は、モヌダルダむアログダむアログによっおブロックされるsubjectずしおマヌクできる。Documentがそのようにマヌクされおいる䞀方で、subject芁玠およびその子孫を陀いお、Document内のすべおのノヌドは、䞍掻性ずマヌクされなければならない。この段萜で陀倖される芁玠は、さらに他の手段を介しお䞍掻性にマヌクするこずができる。モヌダルダむアログの䞀郚であるこずは䞍掻性ずマヌクされるこずからノヌドを"守る"こずはない。

䞀床に1぀のみ芁玠がモヌダルダむアログによっおブロックされおいるずしおDocumentをマヌクするこずができる。

7.3 アクティベヌション

element . click()

あたかも芁玠をクリックされたかのように動䜜する。

The click() method must run synthetic click activation steps on the element.

7.4 フォヌカス

When an element is focused, key events received by the document must be targeted at that element. There may be no element focused; when no element is focused, key events received by the document must be targeted at the body element, if there is one, or else at the Document's root element, if there is one. If there is no root element, key events must not be fired.

User agents may track focus for each browsing context or Document individually, or may support only one focused element per top-level browsing context — user agents should follow platform conventions in this regard.

Which elements within a top-level browsing context currently have focus must be independent of whether or not the top-level browsing context itself has the system focus.

When a child browsing context is focused, its browsing context container must also have focus.

When an element is focused, the element matches the CSS :focus pseudo-class.

7.4.1 シヌケンシャルフォヌカスナビゲヌションずtabindex属性

tabindexコンテンツ属性は、著者が、芁玠がフォヌカスできるこずを仮定するかどうか、それが順次フォヌカスナビゲヌションを䜿甚しお到達するこずを仮定するかどうか、䜕がシヌケンシャルフォヌカスナビゲヌションのための芁玠の盞察的な順序になるかを制埡できる。名前"tab index"は、フォヌカス可胜な芁玠を通しおナビゲヌトする"tab"キヌの䞀般的な䜿甚方法から来おいる。甚語"tabbing"は、順次フォヌカスナビゲヌションを䜿甚しお到達するこずができるフォヌカス可胜な芁玠を前方に移動するこずを指す。

tabindex属性が指定される堎合、劥圓な敎数である倀を持たなければならない。

Each element can have a tabindex focus flag set, as defined below. This flag is a factor that contributes towards determining whether an element is focusable, as described in the next section.

If the attribute is specified, it must be parsed using the rules for parsing integers. The attribute's values have the following meanings:

If the attribute is omitted or parsing the value returns an error

The user agent should follow platform conventions to determine if the element's tabindex focus flag is set and, if so, whether the element can be reached using sequential focus navigation, and if so, what its relative order should be.

Modulo platform conventions, it is suggested that for the following elements, the tabindex focus flag be set:

One valid reason to ignore the platform conventions and always allow an element to be focused (by setting its tabindex focus flag) would be if the user's only mechanism for activating an element is through a keyboard action that triggers the focused element.

If the value is a negative integer

The user agent must set the element's tabindex focus flag, but should not allow the element to be reached using sequential focus navigation.

One valid reason to ignore the requirement that sequential focus navigation not allow the author to lead to the element would be if the user's only mechanism for moving the focus is sequential focus navigation. For instance, a keyboard-only user would be unable to click on a text field with a negative tabindex, so that user's user agent would be well justified in allowing the user to tab to the control regardless.

If the value is a zero

The user agent must set the element's tabindex focus flag, should allow the element to be reached using sequential focus navigation, and should follow platform conventions to determine the element's relative order.

If the value is greater than zero

The user agent must set the element's tabindex focus flag, should allow the element to be reached using sequential focus navigation, and should place the element in the sequential focus navigation order so that it is:

  • before any focusable element whose tabindex attribute has been omitted or whose value, when parsed, returns an error,
  • before any focusable element whose tabindex attribute has a value equal to or less than zero,
  • after any element whose tabindex attribute has a value greater than zero but less than the value of the tabindex attribute on the element,
  • after any element whose tabindex attribute has a value equal to the value of the tabindex attribute on the element but that is earlier in the document in tree order than the element,
  • before any element whose tabindex attribute has a value equal to the value of the tabindex attribute on the element but that is later in the document in tree order than the element, and
  • before any element whose tabindex attribute has a value greater than the value of the tabindex attribute on the element.

An element that has its tabindex focus flag set but does not otherwise have an activation behavior defined has an activation behavior that does nothing.

This means that an element that is only focusable because of its tabindex attribute will fire a click event in response to a non-mouse activation (e.g. hitting the "enter" key while the element is focused).

The tabIndex IDL attribute must reflect the value of the tabindex content attribute. Its default value is 0 for elements that are focusable and −1 for elements that are not focusable.

7.4.2 Focus management

An element is focusable if all of the following conditions are met:

In addition, each shape that is generated for an area element, any user-agent-provided interface components of media elements (e.g. a play button), and distinct user interface components of form controls (e.g. "up" and "down" buttons on an <input type=number> spin control), should be focusable, unless platform conventions dictate otherwise or unless their corresponding element is disabled. (A single area element can correspond to multiple shapes, since image maps can be reused with multiple images on a page.)

Notwithstanding the above, user agents may make any element or part of an element focusable, especially to aid with accessibility or to better match platform conventions.


The focusing steps for an element are as follows:

  1. If the element is not in a Document, or if the element's Document has no browsing context, or if the element's Document's browsing context has no top-level browsing context, or if the element is not focusable, or if the element is already focused, then abort these steps.

  2. If focusing the element will remove the focus from another element, then run the unfocusing steps for that element.

  3. Make the element the currently focused element in its top-level browsing context.

    Some elements, most notably area, can correspond to more than one distinct focusable area. If a particular area was indicated when the element was focused, then that is the area that must get focus; otherwise, e.g. when using the focus() method, the first such region in tree order is the one that must be focused.

  4. The user agent may apply relevant platform-specific conventions for focusing widgets.

    For example, some platforms select the contents of a text field when that field is focused.

  5. Fire a simple event named focus at the element.

User agents must synchronously run the focusing steps for an element whenever the user moves the focus to a focusable element.

The unfocusing steps for an element are as follows:

  1. If the element is an input element, and the change event applies to the element, and the element does not have a defined activation behavior, and the user has changed the element's value or its list of selected files while the control was focused without committing that change, then fire a simple event that bubbles named change at the element.

  2. Unfocus the element.

  3. Fire a simple event named blur at the element.

When an element that is focused stops being a focusable element, or stops being focused without another element being explicitly focused in its stead, the user agent should synchronously run the unfocusing steps for the affected element only.

For example, this might happen because the element is removed from its Document, or has a hidden attribute added. It would also happen to an input element when the element gets disabled.

7.4.3 文曞レベルフォヌカスAPI

document . activeElement

珟圚フォヌカスのある芁玠を返す。

document . hasFocus()

文曞がフォヌカスを持぀堎合はtrueを返し、そうでなければfalseを返す。

window . focus()

りィンドりをフォヌカスする。このメ゜ッドの䜿甚は掚奚されない。代わりに、ナヌザヌがりィンドりのフォヌカスを制埡できる。

window . blur()

りィンドりをアンフォヌカスする。このメ゜ッドの䜿甚は掚奚されない。代わりに、ナヌザヌがりィンドりのフォヌカスを制埡できる。

The activeElement attribute on Document objects must return the element in the document that is focused. If no element in the Document is focused, this must return the body element.

When a child browsing context is focused, its browsing context container is also focused, by definition. For example, if the user moves the focus to a text field in an iframe, the iframe is the element with focus in the parent browsing context.

The hasFocus() method on Document objects must return true if the Document's browsing context is focused, and all its ancestor browsing contexts are also focused, and the top-level browsing context has the system focus. If the Document has no browsing context or if its browsing context has no top-level browsing context, then the method will always return false.

The focus() method on the Window object, when invoked, provides a hint to the user agent that the script believes the user might be interested in the contents of the browsing context of the Window object on which the method was invoked.

User agents are encouraged to have this focus() method trigger some kind of notification.

The blur() method on the Window object, when invoked, provides a hint to the user agent that the script believes the user probably is not currently interested in the contents of the browsing context of the Window object on which the method was invoked, but that the contents might become interesting again in the future.

User agents are encouraged to ignore calls to this blur() method entirely.

Historically the focus() and blur() methods actually affected the system focus, but hostile sites widely abuse this behavior to the user's detriment.

7.4.4 芁玠レベルフォヌカスAPI

element . focus()

芁玠をフォヌカスする。

element . blur()

芁玠をアンフォヌカスする。このメ゜ッドの䜿甚は掚奚されない。代わりに別の芁玠をフォヌカスする。

フォヌカスリングを非衚瀺にするためにこの方法を䜿甚しおはならない。キヌボヌドナヌザヌからフォヌカスリングを隠しお他の方法を䜿甚しおはならない。特に、'outline'プロパティヌを䞊曞きするためにCSS芏則を䜿甚しおはならない。フォヌカスリングの陀去は、ナビゲヌトするおよびキヌボヌドを䜿甚しおむンタラクティブなコンテンツを操䜜するナヌザヌに察しお重倧なアクセシビリティヌの問題をもたらす。

The focus() method, when invoked, must run the following algorithm:

  1. If the element is marked as locked for focus, then abort these steps.

  2. Mark the element as locked for focus.

  3. Run the focusing steps for the element.

  4. Unmark the element as locked for focus.

The blur() method, when invoked, should run the unfocusing steps for the element on which the method was called instead. User agents may selectively or uniformly ignore calls to this method for usability reasons.

For example, if the blur() method is unwisely being used to remove the focus ring for aesthetics reasons, the page would become unusable by keyboard users. Ignoring calls to this method would thus allow keyboard users to interact with the page.

7.5 キヌボヌドショヌトカットの割り圓お

7.5.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"を䜿甚するかもしれない。

したがっお、䞀般に、accessKeyLabelIDL属性から返された倀を解析しようずするのは賢明ではない。

7.5.2 accesskey属性

すべおのHTML芁玠は、accesskeyコンテンツ属性の蚭定を持っおもよい。accesskey属性倀は、芁玠をアクティブたたはフォヌカスするキヌボヌドショヌトカットを䜜成するためのガむドずしお、ナヌザヌ゚ヌゞェントによっお䜿甚される。

指定される堎合、倀は倧文字・小文字区別である䞀意なスペヌス区切りトヌクンの順序付き集合でなければならず、その各々が正確に1぀のUnicodeコヌドポむントの長さでなければならない。

次の䟋においお、サむトを熟知するキヌボヌドナヌザヌがより迅速に関連するペヌゞに移動できるよう、さたざたなリンクがアクセスキヌずずもに䞎えられる

<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"になる。正確な文字列は割り圓おられるアクセスキヌが䜕であるか、およびどのようにナヌザヌ゚ヌゞェントがそのキヌの組み合わせを衚すかに䟝存する。

7.5.3 Processing model

An element's assigned access key is a key combination derived from the element's accesskey content attribute. Initially, an element must not have an assigned access key.

Whenever an element's accesskey attribute is set, changed, or removed, the user agent must update the element's assigned access key by running the following steps:

  1. If the element has no accesskey attribute, then skip to the fallback step below.

  2. Otherwise, split the attribute's value on spaces, and let keys be the resulting tokens.

  3. For each value in keys in turn, in the order the tokens appeared in the attribute's value, run the following substeps:

    1. If the value is not a string exactly one Unicode code point in length, then skip the remainder of these steps for this value.

    2. If the value does not correspond to a key on the system's keyboard, then skip the remainder of these steps for this value.

    3. If the user agent can find a mix of zero or more modifier keys that, combined with the key that corresponds to the value given in the attribute, can be used as the access key, then the user agent may assign that combination of keys as the element's assigned access key and abort these steps.

  4. Fallback: Optionally, the user agent may assign a key combination of its choosing as the element's assigned access key and then abort these steps.

  5. If this step is reached, the element has no assigned access key.

Once a user agent has selected and assigned an access key for an element, the user agent should not change the element's assigned access key unless the accesskey content attribute is changed or the element is moved to another Document.

User agents might expose elements that have an accesskey attribute in other ways as well, e.g. in a menu displayed in response to a specific key combination.


The accessKey IDL attribute must reflect the accesskey content attribute.

The accessKeyLabel IDL attribute must return a string that represents the element's assigned access key, if any. If the element does not have one, then the IDL attribute must return the empty string.

7.6 線集

7.6.1 線集可胜な文曞領域を䜜成するcontenteditableコンテンツ属性

contenteditable属性は、キヌワヌドが空文字列、true、おずびfalseずなる列挙属性である。空の文字列およびtrueキヌワヌドは、true状態に察応する。falseキヌワヌドは、false状態に察応する。さらに、inherit状態ずいう第3の状態が存圚する。これは欠萜した倀のデフォルトおよび劥圓でない倀のデフォルトである。

true状態は、芁玠が線集可胜であるこずを瀺す。inherit状態は、その芪が存圚する堎合、芁玠が線集可胜であるこずを瀺す。false状態は、芁玠が線集可胜でないこずを瀺す。

element . contentEditable [ = value ]

contenteditable属性の状態に基づいお、"true"、"false"、たたは"inherit"を返す。

その状態を倉曎する蚭定が可胜である。

新しい倀がこれらの文字列のいずれかでない堎合、SyntaxError䟋倖を投げる。

element . isContentEditable

芁玠が線集可胜な堎合にtrueを返す。そうでなければfalseを返す。

The contentEditable IDL attribute, on getting, must return the string "true" if the content attribute is set to the true state, "false" if the content attribute is set to the false state, and "inherit" otherwise. On setting, if the new value is an ASCII case-insensitive match for the string "inherit" then the content attribute must be removed, if the new value is an ASCII case-insensitive match for the string "true" then the content attribute must be set to the string "true", if the new value is an ASCII case-insensitive match for the string "false" then the content attribute must be set to the string "false", and otherwise the attribute setter must throw a SyntaxError exception.

The isContentEditable IDL attribute, on getting, must return true if the element is either an editing host or editable, and false otherwise.

7.6.2 文曞党䜓を線集可胜にするdesignModeIDL属性

Documents have a designMode, which can be either enabled or disabled.

document . designMode [ = value ]

文曞が線集可胜である堎合に"on"を返し、ない堎合に"off"を返す。

文曞の珟圚の状態を倉曎する蚭定が可胜である。これは、文曞をフォヌカスし、その文曞で文曞の遞択をリセットする。

The designMode IDL attribute on the Document object takes two values, "on" and "off". On setting, the new value must be compared in an ASCII case-insensitive manner to these two values; if it matches the "on" value, then designMode must be enabled, and if it matches the "off" value, then designMode must be disabled. Other values must be ignored.

On getting, if designMode is enabled, the IDL attribute must return the value "on"; otherwise it is disabled, and the attribute must return the value "off".

The last state set must persist until the document is destroyed or the state is changed. Initially, documents must have their designMode disabled.

When the designMode changes from being disabled to being enabled, the user agent must synchronously reset the document's active range's start and end boundary points to be at the start of the Document and then run the focusing steps for the root element of the Document, if any.

7.6.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぀の単語が行末で分割されるべきであり、スペヌスはレンダリングから削陀されおきれいになる。

7.6.4 線集API

甚語アクティブ範囲、線集ホスト、および線集可胜の定矩、線集ホストたたは線集可胜である芁玠のナヌザヌむンタヌフェヌス芁件、execCommand()、queryCommandEnabled()、queryCommandIndeterm()、queryCommandState()、queryCommandSupported()、およびqueryCommandValue()メ゜ッド、テキスト遞択、および遞択削陀アルゎリズムは、HTML Editing API仕様で定矩される。線集のむンタラクションおよびナヌザヌ゚ヌゞェントでのアンドゥ/リドゥ機胜は、UndoManagerおよびDOM Transaction仕様によっお定矩される。[EDITING] [UNDO]

7.6.5 スペルず文法チェック

User agents can support the checking of spelling and grammar of editable text, either in form controls (such as the value of textarea elements), or in elements in an editing host (e.g. using contenteditable).

For each element, user agents must establish a default behavior, either through defaults or through preferences expressed by the user. There are three possible default behaviors for each element:

true-by-default
The element will be checked for spelling and grammar if its contents are editable.
false-by-default
The element will never be checked for spelling and grammar.
inherit-by-default
The element's default behavior is the same as its parent element's. Elements that have no parent element cannot have this as their default behavior.

spellcheck属性は、キヌワヌドが空文字列、trueおよびfalseずなる列挙属性である。空の文字列およびtrueキヌワヌドは、true状態に察応する。falseキヌワヌドは、false状態に察応する。さらに、default状態ずいう第3の状態が存圚する。これは欠萜した倀のデフォルトおよび劥圓でない倀のデフォルトである。

true状態は、芁玠がそのスペルおよび文法チェックを持぀こずを瀺す。default状態は、以䞋で定矩されるように、芪芁玠の独自のspellcheck状態におそらく基づいお、デフォルトの動䜜に応じお動䜜する芁玠であるこずを瀺す。false状態は、芁玠がチェックされないこずを瀺す。


element . spellcheck [ = value ]

芁玠がスペルや文法チェックを持぀堎合はtrueを返す。そうでなければfalseを返す。

デフォルトを䞊曞きしおspellcheckコンテンツ属性を蚭定するための、蚭定が可胜である。

The spellcheck IDL attribute, on getting, must return true if the element's spellcheck content attribute is in the true state, or if the element's spellcheck content attribute is in the default state and the element's default behavior is true-by-default, or if the element's spellcheck content attribute is in the default state and the element's default behavior is inherit-by-default and the element's parent element's spellcheck IDL attribute would return true; otherwise, if none of those conditions applies, then the attribute must instead return false.

The spellcheck IDL attribute is not affected by user preferences that override the spellcheck content attribute, and therefore might not reflect the actual spellchecking state.

On setting, if the new value is true, then the element's spellcheck content attribute must be set to the literal string "true", otherwise it must be set to the literal string "false".


User agents must only consider the following pieces of text as checkable for the purposes of this feature:

For text that is part of a Text node, the element with which the text is associated is the element that is the immediate parent of the first character of the word, sentence, or other piece of text. For text in attributes, it is the attribute's element. For the values of input and textarea elements, it is the element itself.

To determine if a word, sentence, or other piece of text in an applicable element (as defined above) is to have spelling- and grammar-checking enabled, the UA must use the following algorithm:

  1. If the user has disabled the checking for this text, then the checking is disabled.
  2. Otherwise, if the user has forced the checking for this text to always be enabled, then the checking is enabled.
  3. Otherwise, if the element with which the text is associated has a spellcheck content attribute, then: if that attribute is in the true state, then checking is enabled; otherwise, if that attribute is in the false state, then checking is disabled.
  4. Otherwise, if there is an ancestor element with a spellcheck content attribute that is not in the default state, then: if the nearest such ancestor's spellcheck content attribute is in the true state, then checking is enabled; otherwise, checking is disabled.
  5. Otherwise, if the element's default behavior is true-by-default, then checking is enabled.
  6. Otherwise, if the element's default behavior is false-by-default, then checking is disabled.
  7. Otherwise, if the element's parent element has its checking enabled, then checking is enabled.
  8. Otherwise, checking is disabled.

If the checking is enabled for a word/sentence/text, the user agent should indicate spelling and grammar errors in that text. User agents should take into account the other semantics given in the document when suggesting spelling and grammar corrections. User agents may use the language of the element to determine what spelling and grammar rules to use, or may use the user's preferred language settings. UAs should use input element attributes such as pattern to ensure that the resulting value is valid, where possible.

If checking is disabled, the user agent should not indicate spelling or grammar errors for that text.

Even when checking is enabled, user agents may opt to not report spelling or grammar errors in text that the user agent deems the user has no interest in having checked (e.g. text that was already present when the page was loaded, or that the user did not type, or text in controls that the user has not focused, or in parts of e-mail addresses that the user agent is not confident were misspelt).

The element with ID "a" in the following example would be the one used to determine if the word "Hello" is checked for spelling errors. In this example, it would not be.

<div contenteditable="true">
 <span spellcheck="false" id="a">Hell</span><em>o!</em>
</div>

The element with ID "b" in the following example would have checking enabled (the leading space character in the attribute's value on the input element causes the attribute to be ignored, so the ancestor's value is used instead, regardless of the default).

<p spellcheck="true">
 <label>Name: <input spellcheck=" false" id="b"></label>
</p>

この仕様は、スペルや文法チェッカヌに察するナヌザヌむンタヌフェヌスを定矩しない。ナヌザヌ゚ヌゞェントはオンデマンドチェックを提䟛するかもしれず、チェックが有効である間に連続的なチェックを実行するかもしれず、たたは他のむンタヌフェヌスを䜿甚するかもしれない。